Hello,
I have put the {cms_selflink dir="prev"} and {cms_selflink dir="next"} tags in my template. Here is my menu :
1- Home (page)
2- News (page)
3- Infos (page with coords, access map and contact form)
4- Access map (internal link/anchor)
5- Contact (internal link/anchor)
6- Credits (page)
My problem is that I can't navigate (using prev/next links) to the credits page, because cms_selflink tags include links with anchors (items 4 and 5 in above menu).
Any idea how I could exclude those two links from the cms_selflink tag please ?
Something like {cms_selflink dir="prev" exclude="4,5"}{cms_selflink dir="next" exclude="4,5"} would fit, but I don't think it exists...
Note : Unforunately I can't remove the anchors from the menu itself, that's a customer requirement...
Thank you.
How to exclude pages from cms_selflink prev/next ?
-
- Forum Members
- Posts: 10
- Joined: Wed Aug 13, 2008 8:42 am
-
- Forum Members
- Posts: 10
- Joined: Wed Aug 13, 2008 8:42 am
Re: How to exclude pages from cms_selflink prev/next ?
I have tried this :
This hides the unwanted links, but doesn't solve my problem : I would like the prev/next link to "skip" anchors and dispay the real prev/next page...
Code: Select all
{cms_selflink dir="prev" assign="prevlink"}{if !$prevlink|strstr:"#"}{$prevlink}{/if}
{cms_selflink dir="next" assign="nextlink"}{if !$nextlink|strstr:"#"}{$nextlink}{/if}
Re: How to exclude pages from cms_selflink prev/next ?
I dont know how your pages are showing seperate from what you have listed, but what if you mark the page 4/5 as non-showing in menu. Then the menu-call could be a show_all=1call, to show the hidden pages as well. Then the cms_selflink will skip the hidden pages IIRC.
This is depending if you have other non-showing pages, as they woul become visible as well in the call..
Ronny
This is depending if you have other non-showing pages, as they woul become visible as well in the call..
Ronny
-
- Forum Members
- Posts: 10
- Joined: Wed Aug 13, 2008 8:42 am
Re: How to exclude pages from cms_selflink prev/next ?
I finally copied some code from plugins/function.cms_selflink.php and created my own user tags :
{prev_link} :
{next_link} :
This is not very "smart" but it works...
{prev_link} :
Code: Select all
global $gCms;
$manager = & $gCms->GetHierarchyManager();
$pages = & $manager->getFlatList();
$number = 0;
for ($i=0;$i<count($pages);$i++){
if ($pages[$i]->getTag() == $gCms->variables['content_id']){
$number = $i;
break;
}
}
$pageid = null;
if ($number > 0){
for ($i = $number - 1; $i >= 0; $i--){
$content =& $pages[$i]->getContent();
if (isset($content) && $content != NULL){
if ($content->Active() && $content->ShowInMenu() && $content->HasUsableLink() && !strstr($content->GetURL(),'#')){
$pageid = $content->Id();
$alias = $content->Alias();
$name = $content->Name();
$menu_text = $content->MenuText();
$url = $content->GetURL();
$titleattr = $content->TitleAttribute();
break;
}
}else{
break;
}
}
}
if (!empty($pageid)){
echo '<a class="button" title="'.$name.'" href="'.$url.'"><span>Previous page</span></a>';
}
Code: Select all
global $gCms;
$manager = & $gCms->GetHierarchyManager();
$pages = & $manager->getFlatList();
$number = 0;
for ($i=0;$i<count($pages);$i++){
if ($pages[$i]->getTag() == $gCms->variables['content_id']){
$number = $i;
break;
}
}
$pageid = null;
if ($number > 0){
for ($i = $number + 1; $i < count($pages); $i++){
$content =& $pages[$i]->getContent();
if (isset($content) && $content != NULL){
if ($content->Active() && $content->ShowInMenu() && $content->HasUsableLink() && !strstr($content->GetURL(),'#')){
$pageid = $content->Id();
$alias = $content->Alias();
$name = $content->Name();
$menu_text = $content->MenuText();
$url = $content->GetURL();
$titleattr = $content->TitleAttribute();
break;
}
}else{
break;
}
}
}
if (!empty($pageid)){
echo '<a class="button" title="'.$name.'" href="'.$url.'"><span>Next page</span></a>';
}
-
- Forum Members
- Posts: 10
- Joined: Wed Aug 13, 2008 8:42 am
Re: How to exclude pages from cms_selflink prev/next ?
Hello Ronny,
Thank you, that would have been cleverer, but unfortunately I have lots of pages that can't be shown on menu...
Thank you, that would have been cleverer, but unfortunately I have lots of pages that can't be shown on menu...