Sign In
Start Page | Recent Changes | All Pages | Orphan Pages | Junebug Help

Comparing version 8 and version 7

Global tags are Radius rags like  that work on all pages and do not require specifying a Behavior for the page. 

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]].

h2. Examples

h3. 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. h3. 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. h3. 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:

{{{
 
Go up
 
}}}


This will create a link to the parent page that says "Go up".

Back to Page