Hi,
I’m trying to use the {exp:static_tome_path} tag to build a nested set of links to a set of my tome pages. The tag works fine when I am viewing a tome page, but it does not work when I call it from a non-tome page.
What I mean is if I have this tag:
{exp:static_tome_path direction="post" page="23" depth="0"}
<a href="http://{url_title}" title="{title}">{title}</a>
{/exp:static_tome_path}
in an embed which is called via my header into all pages of my site, when I am on the front page it just gives me {title}. If I am viewing a page which is set up as a static page in tome, then the tag works fine.
How can I get the links showing correctly on all pages?
That is a shame. Hardcoding was not an option for me, it kind of negates the usefulness of the Tome module - i.e. clients managing the pages themselves.
I have come up with a way around it however. My method is a way of building links to tome children pages from a given category ID. It builds correct tome links in the format of http://site.com/cat_url_title/cat_url_title/cat_url_title/..etc etc
It requires a hack to MF’s breadcrumb plugin (http://ellislab.com/forums/viewthread/27264/) to allow the plugin to return the cat_url_title – which is used by tome to build the path to a Tome page.
In pi.breadcrumb.php alter the SQL query around line 218 to return cat_url_title
:
$sql = "SELECT cat_id, parent_id, cat_name, cat_image, cat_description, cat_order, cat_url_title
FROM exp_categories
WHERE cat_id = '".$DB->escape_str($this->current_parent_category($current_category))."' ";
Then, around line 270, duplicate one of the blocks that parses the variables, and alter it to return the cat_url_title variable:
//parse cat_url_title variable
if ($key == 'category_url_title')
{
if (isset($query->row['cat_url_title']))
{
$tagdata = $TMPL->swap_var_single($val, $query->row['cat_url_title'], $tagdata);
}
}
Now you can access the cat_url_title column with the breadcrumb plugin via {category_url_title}, i.e.
{exp:breadcrumb root_node="XX"}{category_url_title}/{/exp:breadcrumb}
Now to show a list of links to one level of Tome pages from a non-Tome page I do the following…
Create a link to a new embedded template, and pass it the root ID that you want to show the sub-page links for:
{embed="embeds/.left_staticpages" rootid="23"}
In the embedded template use a custom query to grab the children of the root node. Then when you are looping through the results, use the breadcrumb plugin on each one to walk up the hierarchy building the URL to the Tome page using the cat_url_title field:
{exp:query sql="SELECT cat_id as category_id2, cat_name AS category_name2, cat_url_title AS cat_url_title2 FROM exp_categories WHERE parent_id = '{embed:rootid}' ORDER BY cat_order ASC"}
{if count == 1}
<ul >
{/if}
<li>
<a href="http://{path=node={category_id2}">{category_name2}</a></li>
{if count == total_results}
</ul>
<hr >
{/if}
{/exp:query}
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.