Hi Susan,
Thank you for your suggestion, but had already proved it, unfortunately without result. The only solution is not to use the ’&displayStart’ option, then the result is correct, you get the last 5 documents ordered more recents first. The problem is I can’t get the correct styles aplied because I can’t get the ’startItemTpl’ parsed by Wayfinder.
Anyway, I found a workaround that allows me to implement the required styles, the problem is how I mounted the TV, chuncks and Templates to use the same ’template chunks’ for 3 diferent Wayfinder calls chunks, perhaps, it might be better to start from the beginning to clarify what I am doing and why I need to modify Wayfinder.
Wayfinder used version 2.0.
The ultimate goal is to get 3 separate menus located in the right column below one another, like this:
LAST ARTICLES- Most recent article here
- Here the second most recent
- And so on
- until...
- the specified value of ’&limit’ Wayfinder call option.
LAST NOTES
- ... Same as first, but for Notes ...
LAST NEWS
- ... Same as first, but for News ...
Depending on the value of a TV called ’Last’ type ’checkbox’ and that allows you check the values: ’Notes’,’ News’ and ’ Articles’, you get ’none’, one, two or all the ’menus’ displayed. I put in ’Input Option Values’ of ’Last’ TV:
Articles=={{LastArticles}}||Notes=={{LastNotes}}||News=={{LastNews}}
The ’Last’ TV is assigned to a template with the ’[*Last*]’ placehoder on the needed page position for proper display. Bellow the Wayfinder calls carried out by ’chunks’ allocated in the ’Last’ TV.
NOTE: The 3 chunks share exactly the same code, the only option that I change every call is ’&startId’.
NOTE: Some of the ’CODE:’ containers of this post are wraped for legibility.
The following code runs without hacking ’Wayfinder’, but you get the ’first 5 documents’ (usually, they are the oldest) on container suplied on ’&startID’ option, in this case ’Articles’ (ID = 2) ordered depending on the value of the ’&sortOrder’ option which, by default, is ’ASC’.
[!Wayfinder? &startId=`2` &limit=`5` &sortBy=`published` &textOfLinks=`pagetitle`
&displayStart=`TRUE` &startItemTpl=`Last_Wayfinder_startItemTpl`
&rowTpl=`Last_Wayfinder_rowTpl` &outerTpl=`Last_Wayfinder_outerTpl`!]
With this call you get the following menu:
LAST ARTICLES- First article on ’Articles’ container
- Here the second
- the 3th
- 4th
- and the 5th, the last one
NOTE: The templates are detailed below.
But what I want to get, are the ’5 most recent’ documents on the suplied container (&startID) ordered most recents first.
After reading for the umpteenth time the ’Wayfinder’ documentation and read his code, I have not found any way to make the selection I want without change ’slightly’ Wayfinder. I only need to add the field ’,sc.createdon’ to the ’$fields’ variable in the ’getData’ function on ’/assets/snippets/wayfinder/wayfinder.inc.php’ file.
Before change:
$fields = "sc.id, sc.menutitle, sc.pagetitle, sc.introtext, sc.menuindex, sc.published, sc.hidemenu,
sc.parent, sc.isfolder, sc.description, sc.alias, sc.longtitle, sc.type,
if(sc.type='reference',sc.content,'') as content, sc.template, sc.link_attributes";
After change:
$fields = "sc.id, sc.menutitle, sc.pagetitle, sc.introtext, sc.menuindex, sc.createdon, sc.published,
sc.hidemenu, sc.parent, sc.isfolder, sc.description, sc.alias, sc.longtitle,
sc.type,if(sc.type='reference',sc.content,'') as content, sc.template, sc.link_attributes";
Theoretically, after this amendment, I should be able to call ’Wayfinder’ with the ’&sortBy’ option value set to ’createdon’ and obtain the desired result. And that is! When I call ’Wayfinder’ with the bellow code:
[!Wayfinder? &startId=`2` &limit=`5` &sortBy=`createdon` &sortOrder=`DESC` &textOfLinks=`pagetitle`
&rowTpl=`Last_Wayfinder_rowTpl` &outerTpl=`Last_Wayfinder_outerTpl`!]
I get the desired result. But unfortunately, if the call to ’Wayfinder’ includes the ’&displayStart’ option with the value set to ’TRUE’, you get nothing. Test the code bellow to get nothing:
[!Wayfinder? &startId=`2` &limit=`5` &sortBy=`createdon` &sortOrder=`DESC` &textOfLinks=`pagetitle`
&rowTpl=`Last_Wayfinder_rowTpl` &outerTpl=`Last_Wayfinder_outerTpl` &displayStart=`TRUE`
&startItemTpl=`Last_Wayfinder_startItemTpl`!]
But without the ’Last_Wayfinder_startItemTpl’ I can’t use the same templates chunks for the 3 ’Wayfinder’ calls chunks (Articles, Notes and News) and I need 3 slightly diferents ’outerTpl’ templates for do the same job. To fully understand the problem, I detailed below the templates code.
First the ’startItemTpl’ template:
<div>
<ul class="Last">Recents [+wf.linktext+]
[+wf.wrapper+]
Next the ’rowTpl’ template:
<li><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a>[+wf.wrapper+]</li>
And finally the ’outerTpl’ template:
As you can see in the ’startItemTpl’ template code, I use the [+wf.linktext+] placeholder to get the name of the page title of the container document (&startID), this way, after parsed, you get the ’Recents Articles’, ’Recents Notes’ or ’Recents News’ menu header automatically generated with one simple template chunk. The ’rowTpl’ is very usual, no comments needed, but the ’outerTpl’ is a little different than usual, because I use it to close the ’<div>’, I test the same call without ’outerTpl’ and using only the ’startItemTpl’ coded as you can see bellow:
The ’startItemTpl’ template:
<div>
<ul class="Last">Recents [+wf.linktext+]
[+wf.wrapper+]
</ul>
</div>
With the same result, with ’Wayfinder’ unmodified. But with the ’hack’ you can’t use the ’&displayStart’ option, I don’t know why, and if I change and use the ’&outerTpl’ template including the same code used in ’startItemTpl’, like you can read in the previous code chunk, then you don’t get the [+wf.linktext+] placeholder parsed.
As I said at the beginning, I have found a workaround, because obviously, the solution is simple, the problem is that I don’t think it’s a very elegant solution.
The simplest solution that I have found is to use 3 different chunks template one for each type of menu, see below:
<div>
<ul class="Last">Recents Articles
[+wf.wrapper+]
</ul>
</div>
I have assigned the above code to a chunk called ’LastArticles_Wayfinder_outerTpl’ and have created two more chunks with the same code and changing only the word ’Articles’ to’ Notes’ or ’News’ for chunks ’LastNotes_Wayfinder_outerTpl’ and ’LastNews_Wayfinder_outerTpl’ respectively.
Thus, calling ’Wayfinder’ with a slightly different code every time, you get the expected result. See bellow:
’LastArticles’ chunk ’Wayfinder’ call:
[!Wayfinder? &startId=`2` &limit=`5` &sortBy=`createdon` &sortOrder=`DESC` &textOfLinks=`pagetitle`
&rowTpl=`Last_Wayfinder_rowTpl` &outerTpl=`LastArticles_Wayfinder_outerTpl`!]
’LastNotes’ chunk ’Wayfinder’ call:
[!Wayfinder? &startId=`76` &limit=`5` &sortBy=`createdon` &sortOrder=`DESC` &textOfLinks=`pagetitle`
&rowTpl=`Last_Wayfinder_rowTpl` &outerTpl=`LastNotes_Wayfinder_outerTpl`!]
’LastNews’ chunk ’Wayfinder’ call:
[!Wayfinder? &startId=`75` &limit=`5` &sortBy=`createdon` &sortOrder=`DESC` &textOfLinks=`pagetitle`
&rowTpl=`Last_Wayfinder_rowTpl` &outerTpl=`LastNews_Wayfinder_outerTpl`!]
If someone has a better and more elegant way to obtain the same result, we greatly appreciate a bit of text.
FOR DEVELOPPERS, Kyle and Ryan
If you found the amendment interesting enough for inclusion in a future version of ’Wayfinder,’ while the problem of the ’&displayStart’ option persists, I would suggest to add to the ’Wayfinder’ snippet calling the ’wayfinder.inc.php’ file the following code after the ’Wayfinder’ class instantiation and before the ’$wf->_config = array’ declaration to avoid errors:
if ($sortBy === 'createdon')
$displayStart = FALSE;
$wf->_config = array(
.
.
I hope I was able to explain my dilemma.
TIA
Ramon