I make a lot of use of Wayfinder’s automatic [+wf.linktext+] that searches menutitle first and falls back to pagetitle if the former is blank.
When using YAMS I didn’t want to lose this ability and force the client to enter menu titles for every page. I have PHx installed and the following snippet works well (adapted from docr/row.tpl):
<li[+wf.id+][+wf.classes+]>
<a href="(yams_docr:[+wf.docid+])" title="[[YAMS? &get=`data` &docid=`[+wf.docid+]` &from=`pagetitle`]]" [+wf.attributes+]>[+phx:if=`[[YAMS? &get=`data` &docid=`[+wf.docid+]` &from=`menutitle`]]`:eq=``:then=`[[YAMS? &get=`data` &docid=`[+wf.docid+]` &from=`pagetitle`]]`:else=`[[YAMS? &get=`data` &docid=`[+wf.docid+]` &from=`menutitle`]]`+]</a>
[+wf.wrapper+]
</li>
Yes it’s an extra set of database queries, but worth it for convenience.
-
- 805 Posts
Thanks a lot for sharing your solution Peter. Several people have asked about that in the past.
Quote from: Peter at Jul 08, 2010, 02:13 PM
Yes it’s an extra set of database queries, but worth it for convenience.
Actually, there are almost certainly no extra database calls as a result of your modification to the default template. The [tt][[YAMS?...[/tt] snippet outputs [tt]((yams_data:...))[/tt] placeholders. When YAMS parses the page it collects up all those placeholders and combines them into mysql queries sufficient to grab all the info it needs from up to 50 documents at a time, which is far more efficient. Unless it’s a very big site, that normally means that it everything is grabbed in single query.
Quote from: PMS at Jul 08, 2010, 09:20 PM
Actually, there are almost certainly no extra database calls as a result of your modification to the default template.
Ah that’s fantastic to know, and to get more of an insight into how YAMS works. I was beginning to think I’d need a caching server on this site, but all should be well then