How To Define Global Tags
Global tags are Radius rags like
If you have deployed Radiant with the—unpack switch, you can edit app/models/page_context.rb directly.
Alternatively you can write an extension, as covered in Creating_Radiant_Extensions?.
Examples
If Children Exist
To create a new tag that only renders its content when the current page has children, use this code{{{
tag "if_children" do |tag|
tag.expand if tag.locals.page.has_children?
end
}}}
Then in your page write
{{{This will create a unordered list of links to the children of the page, sorted by ascending title, if any exist.
Random Child Page
{{{
tag "children:random" do |tag|
children = tag.locals.children
if children.size > 0
index = rand(children.size)
tag.locals.page = children[index]
tag.expand
end
end
}}}
Then in your page, write
{{{Or just
{{{Note that this will only select one child page, and needs modification to select more than one.
Refer to the Parent Page
{{{ tag “parent” do |tag| tag.locals.page = tag.locals.page.parent tag.expand if tag.locals.page.has_parent? end
tag “if_parent” do |tag| tag.expand if tag.locals.page.has_parent? end
tag “unless_parent” do |tag| tag.expand unless tag.locals.page.has_parent? end }}}
In your page, write this:
{{{This will create a link to the parent page that says “Go up”.
