Exclude certain pages from relational links [SOLVED]
Exclude certain pages from relational links [SOLVED]
Hello.
I am running cmsms 1.6.6. I was wondering if it is possible to exclude certain pages from the relational links (next/previous) at the bottom of the page. The best behavior would skip over certain pages I mark in the template. It would be something like this:
{cms_selflink dir="next" exclude_pages="all the children of the page with the position of 2"}
The other thing I would need is something along these lines:
{cms_selflink dir="next" include_pages="all the children of the page with the position of 2"}
These would both be used in different contexts. Is this possible? How? Help would be appreciated.
Isaac.
I am running cmsms 1.6.6. I was wondering if it is possible to exclude certain pages from the relational links (next/previous) at the bottom of the page. The best behavior would skip over certain pages I mark in the template. It would be something like this:
{cms_selflink dir="next" exclude_pages="all the children of the page with the position of 2"}
The other thing I would need is something along these lines:
{cms_selflink dir="next" include_pages="all the children of the page with the position of 2"}
These would both be used in different contexts. Is this possible? How? Help would be appreciated.
Isaac.
Last edited by isaacd on Mon Feb 22, 2010 5:17 am, edited 1 time in total.
Re: Exclude certain pages from relational links
Reading the Help for the selflink it doesn't look like it is possible...
Re: Exclude certain pages from relational links
Check CGSmarty, that has some parameters you could use....
F.e. to only show relational links for pages on the same level...
F.e. to only show relational links for pages on the same level...
Ronny{$cgsimple->get_sibling("prev","prev_sibling")}{if !empty($prev_sibling)}{cms_selflink page="$prev_sibling" text="Previous"}{/if}
Re: Exclude certain pages from relational links
Thanks RonnyK, good thing to know...
Re: Exclude certain pages from relational links
Hi Ronnyk.
Does the CGSimpleSmarty module come installed on cmsms already? I looked in the module manager and could not find it. I also looked at my installed module and could not find it there either.
Also, could I do something like:
{$cgsimple->get_prevpageposition("previous_page")}
where get_prevpageposition gets the hierarchical position of the previous page, (an alias would work too, but position is preferred), and where ("previous_page") (as stated in parenthesis and quotes) is the variable that is assigned. Presumably, this would allow me to do something like this:
{$cgsimple->get_prevpageposition("previous_page")}
{if $previous_page >= 2 && $previous_page < 3}
{cms_selflink page="1"}
{else}
{cms_selflink dir="prev"}
{/if}
This would cause it to skip over any pages that had a hierarchical position that is anything greater than or equal to 2 and less than 3. The only thing I need now it to know how to get the previous page position, and whether or not cgsimplesmarty comes installed by default.
Thanks.
Isaac.
Does the CGSimpleSmarty module come installed on cmsms already? I looked in the module manager and could not find it. I also looked at my installed module and could not find it there either.
Also, could I do something like:
{$cgsimple->get_prevpageposition("previous_page")}
where get_prevpageposition gets the hierarchical position of the previous page, (an alias would work too, but position is preferred), and where ("previous_page") (as stated in parenthesis and quotes) is the variable that is assigned. Presumably, this would allow me to do something like this:
{$cgsimple->get_prevpageposition("previous_page")}
{if $previous_page >= 2 && $previous_page < 3}
{cms_selflink page="1"}
{else}
{cms_selflink dir="prev"}
{/if}
This would cause it to skip over any pages that had a hierarchical position that is anything greater than or equal to 2 and less than 3. The only thing I need now it to know how to get the previous page position, and whether or not cgsimplesmarty comes installed by default.
Thanks.
Isaac.
Re: Exclude certain pages from relational links
Isaac,
CGSimpleSmarty doesnt come with the default install.. You should additionally install it. Before installing you could read its help in the ModuleManager, under tab C.
For working with the position, I dont really understand what you mean. Could you explain by a little example. I dont see if you mean the current position, or the parent position.
Ronny
CGSimpleSmarty doesnt come with the default install.. You should additionally install it. Before installing you could read its help in the ModuleManager, under tab C.
For working with the position, I dont really understand what you mean. Could you explain by a little example. I dont see if you mean the current position, or the parent position.
Ronny
Re: Exclude certain pages from relational links
Ronny,
I found cgsimplesmarty in the module manager. Apparently I missed it before.
In example, if I had this structure:
Home (1)
About (2)
---Who we are (2.1)
---How we came to be (2.2)
------About our origin (2.2.1)
Contact us (3)
(this is all made up)
then the prevpageposition of about would be 1 (because the page before about is #1). The prevpageposition of Contact us would be 2.2.1. The prevpageposition Who we are would be 2. It is just the page that comes before, no matter what level it is on.
My object here would be to skip over the level two links.
Isaac.
I found cgsimplesmarty in the module manager. Apparently I missed it before.
In example, if I had this structure:
Home (1)
About (2)
---Who we are (2.1)
---How we came to be (2.2)
------About our origin (2.2.1)
Contact us (3)
(this is all made up)
then the prevpageposition of about would be 1 (because the page before about is #1). The prevpageposition of Contact us would be 2.2.1. The prevpageposition Who we are would be 2. It is just the page that comes before, no matter what level it is on.
My object here would be to skip over the level two links.
Isaac.
Re: Exclude certain pages from relational links
Is there a way to simply make a variable for the previous page. This would be exactly like writing {cms_selflink dir="prev"} except that instead of turning into a link, it would turn into a variable? I looked in the /plugins/cms_selflink.php and found something that might be helpful on line 250.
Thanks
Thanks
Re: Exclude certain pages from relational links
With CGSimpleSmarty, you could do something like.... This will only show relational links when the next/prev is on the same level...
F.e. this logic, coming from the help of CGSimpleSmarty, which could be set in the template.
F.e. this logic, coming from the help of CGSimpleSmarty, which could be set in the template.
And the same for the next sibling{$cgsimple->get_sibling("prev","prev_sibling")}{if !empty($prev_sibling)}{cms_selflink page="$prev_sibling" text="Previous"}{/if}
Ronny{$cgsimple->get_sibling("next","next_sibling")}{if !empty($next_sibling)}{cms_selflink page="$next_sibling" text="Next"}{/if}
Re: Exclude certain pages from relational links
Hi Ronnyk
I have got the previous page solved. I changed my navigation structure so that the links I wanted to skip were all children of page 1, not 2. So its like this (hierarchical positions):
--1
----1.1
----1.2
------1.2.1
--------1.2.1.1
--2
----2.1 (etc)
What I did is I put in my template {if $posititon != 2}{cms_selflink dir="prev" label="Previous page:"}{/if}
Now what I need is a way to find the next page. The {$cgsimple->get_sibling("next","next_sibling")} will only work if the next page is on the same level. So I need a way to cascade to the deepest level that has a sibling after it. This requires a while statement which I understand is not incorparated into smarty.
So in the case of the hierarchy above, if I wanted to find out what the page after 1.2.1.1 is, this is what would happen:
--Find out if 1.2.1.1 has any siblings after it ......... No, go up a level
--Find out if 1.2.1 has any siblings after it ......... No, go up a level
--Find out if 1.2 has any siblings after it .......... No, go up a level
--Find out if 1 has any siblings after it .......... Yes, the sibling is page 2
Is it possible (or necessary) to call smarty in php, which has a while loop? That is the only problem now.
Thanks.
Isaac.
I have got the previous page solved. I changed my navigation structure so that the links I wanted to skip were all children of page 1, not 2. So its like this (hierarchical positions):
--1
----1.1
----1.2
------1.2.1
--------1.2.1.1
--2
----2.1 (etc)
What I did is I put in my template {if $posititon != 2}{cms_selflink dir="prev" label="Previous page:"}{/if}
Now what I need is a way to find the next page. The {$cgsimple->get_sibling("next","next_sibling")} will only work if the next page is on the same level. So I need a way to cascade to the deepest level that has a sibling after it. This requires a while statement which I understand is not incorparated into smarty.
So in the case of the hierarchy above, if I wanted to find out what the page after 1.2.1.1 is, this is what would happen:
--Find out if 1.2.1.1 has any siblings after it ......... No, go up a level
--Find out if 1.2.1 has any siblings after it ......... No, go up a level
--Find out if 1.2 has any siblings after it .......... No, go up a level
--Find out if 1 has any siblings after it .......... Yes, the sibling is page 2
Is it possible (or necessary) to call smarty in php, which has a while loop? That is the only problem now.
Thanks.
Isaac.
Re: Exclude certain pages from relational links
Sounds like all you need is default selflink action as it will always go to the prev./next if set like it is in default templates...
Re: Exclude certain pages from relational links
I know that I can use cms_selflink to create a link, but what I want is a variable telling me what the next page is. So I could do something like this:
{if nextpage == something}
do something
{else}
Do something else
{/if}
Thanks.
Isaac
{if nextpage == something}
do something
{else}
Do something else
{/if}
Thanks.
Isaac
Re: Exclude certain pages from relational links
look at cgsimplesmarty
Re: Exclude certain pages from relational links
Yes, I have looked at cgsimplesmarty. I did not find a "next_page" function, but only a "next_sibling". Reffer to post above:
isaacd wrote: --1
----1.1
----1.2
------1.2.1
--------1.2.1.1
--2
----2.1 (etc)
Now what I need is a way to find the next page. The {$cgsimple->get_sibling("next","next_sibling")} will only work if the next page is on the same level. So I need a way to cascade to the deepest level that has a sibling after it. This requires a while statement which I understand is not incorparated into smarty.
So in the case of the hierarchy above, if I wanted to find out what the page after 1.2.1.1 is, this is what would happen:
--Find out if 1.2.1.1 has any siblings after it ......... No, go up a level
--Find out if 1.2.1 has any siblings after it ......... No, go up a level
--Find out if 1.2 has any siblings after it .......... No, go up a level
--Find out if 1 has any siblings after it .......... Yes, the sibling is page 2
Is it possible (or necessary) to call smarty in php, which has a while loop? That is the only problem now.
Thanks.
Isaac.
Re: Exclude certain pages from relational links
I have solved the problem for me. Here is a very comprehensive explanation.
Purpose:
To get rid of the relational links (next/prev page links) depending on where they lead to. For example, if you have in your template:
{cms_selflink dir="next"}
this method would allow you to hide the next link depending on what the next page actually is.
Background Information:
The {cms_selflink dir="next"} will lead the the very next page. For example:
1 Home
2 About
2.1 Who We Are
2.1.1 Our History
2.1.2 Future plans
3 Mission
In the navigation structure above, if {cms_selflink dir="next"} were placed on the about page, it would link to who we are. If {cms_selflink dir="next"} were placed on the "our history" page, it would link to "future plans". If it were placed on the future plans page, it would link to Mission.
Steps: (for excluding a page from the NextLink)
1. First, you need to visit the page directly before the one you want to exclude. So in the example above, If I wanted to exclude mission from the NextLink, I would visit the future Plans page.
2. Go into View >> Page Source. Find where the next link is displayed. Copy the html. What you should copy should be something like this:
Next page: Mission
Be sure to include the label ("Next page:" in the example above), as well as the link. In other words, include any html created by the {cms_selflink dir="next"} tag.
3. Go into the template, and find where the {cms_selflink dir="next"} tag is. Replace it with {cms_selflink dir="next" assign="nextlink"} .
4. Create an if statement as follows (using the example from step 2) using the html you copied
{if $nextlink != 'Next page: Mission'}{$nextlink}{/if}
Explination of Code
Using this example, I will explain the code:
The {cms_selflink dir="next" assign="nextlink"} assigns the contents of {cms_seflink dir="next"} to a variable. This makes it possible to minipulate it with an if statement.
The {if $nextlink != 'Next page: Mission'} checks that the selflink is not linking to a page called Mission. If the contents of {cms_seflink dir="next"} is equal to that of Next page: Mission , then there is a match. The operator != prevents the nextlink from being displayed if the pages match.
The call to {$nextlink} is simply a shorter way of writing out {cms_selflink dir="next"} , becasue {cms_seflink dir="next"} is already contained in the variable $nextlink.
And of course, the if statement must be closed off with {/if}.
Notes
1. You may need to include multiple conditions for the if statement because visitors could visit http://example.com or http://www.example.com . This would look something like this:
{if $nextlink != 'Next page: Mission' || $nextlink != 'Next page: Mission'} .
This is as of yet untested, but I see no reason why it should not work.
2. The condition 'Next page: Mission' MUST BE VERBATIM for the html that {cms_selflink dir="next"} creates. You should also enclose it in single instead of double quotes because there will be double quotes in the html.
{if $nextlink != 'Next page: Mission'}
3. This same process can be done to exclude pages from {cms_selflink dir="prev"} also. Keep in mind if you want to exclude a pages from the relational links completely, you need to do this process once for the NextLink, and once for the PrevLink.
Regards.
Isaac.
Purpose:
To get rid of the relational links (next/prev page links) depending on where they lead to. For example, if you have in your template:
{cms_selflink dir="next"}
this method would allow you to hide the next link depending on what the next page actually is.
Background Information:
The {cms_selflink dir="next"} will lead the the very next page. For example:
1 Home
2 About
2.1 Who We Are
2.1.1 Our History
2.1.2 Future plans
3 Mission
In the navigation structure above, if {cms_selflink dir="next"} were placed on the about page, it would link to who we are. If {cms_selflink dir="next"} were placed on the "our history" page, it would link to "future plans". If it were placed on the future plans page, it would link to Mission.
Steps: (for excluding a page from the NextLink)
1. First, you need to visit the page directly before the one you want to exclude. So in the example above, If I wanted to exclude mission from the NextLink, I would visit the future Plans page.
2. Go into View >> Page Source. Find where the next link is displayed. Copy the html. What you should copy should be something like this:
Next page: Mission
Be sure to include the label ("Next page:" in the example above), as well as the link. In other words, include any html created by the {cms_selflink dir="next"} tag.
3. Go into the template, and find where the {cms_selflink dir="next"} tag is. Replace it with {cms_selflink dir="next" assign="nextlink"} .
4. Create an if statement as follows (using the example from step 2) using the html you copied
{if $nextlink != 'Next page: Mission'}{$nextlink}{/if}
Explination of Code
Using this example, I will explain the code:
Code: Select all
{cms_selflink dir="next" assign="nextlink"}
{if $nextlink != 'Next page: <a href="http://example.com/mission" title="Mission">Mission</a>'}{$nextlink}{/if}
The {if $nextlink != 'Next page: Mission'} checks that the selflink is not linking to a page called Mission. If the contents of {cms_seflink dir="next"} is equal to that of Next page: Mission , then there is a match. The operator != prevents the nextlink from being displayed if the pages match.
The call to {$nextlink} is simply a shorter way of writing out {cms_selflink dir="next"} , becasue {cms_seflink dir="next"} is already contained in the variable $nextlink.
And of course, the if statement must be closed off with {/if}.
Notes
1. You may need to include multiple conditions for the if statement because visitors could visit http://example.com or http://www.example.com . This would look something like this:
{if $nextlink != 'Next page: Mission' || $nextlink != 'Next page: Mission'} .
This is as of yet untested, but I see no reason why it should not work.
2. The condition 'Next page: Mission' MUST BE VERBATIM for the html that {cms_selflink dir="next"} creates. You should also enclose it in single instead of double quotes because there will be double quotes in the html.
{if $nextlink != 'Next page: Mission'}
3. This same process can be done to exclude pages from {cms_selflink dir="prev"} also. Keep in mind if you want to exclude a pages from the relational links completely, you need to do this process once for the NextLink, and once for the PrevLink.
Regards.
Isaac.
Last edited by isaacd on Mon Feb 22, 2010 5:17 am, edited 1 time in total.