Forum
Link to subpage
I have several subpages of news.php: news1.php, news2.php etc. How can I set a link eg. in the index-file to the first subpage? The subpages are created with perch navigation, so the name of the first subpage might change... Thanks a lot!
Yes, you should be able to do that using
from-path
in the navigation options.What do I have to add here to output just the first subpage-link? Thanks for your help, Drew.
I was going to suggest
'count' => 1
but it looks like that's not actually implemented.Next best option might be to wrap your template output in
Unfortunately it's not working...
What happens?
The same. For me logic, we just ask if the first item exists, we would need a consequence then. How can we just output the first page?
"The same" is obviously easily apparent for you to see, but I have no idea what that means. If I'm going to be able to be of any help, you need to describe what you're seeing, what changes you've made to the template and options, and what result you're getting.
Remember that I have no knowledge of your project or what you're trying to achieve.
Of course, sorry! Look what we have actually:
That gives the following output of course:
and so on...
So now my question is: what do I have to add that it outputs just the first a-tag? If I add the «if exists» condition the output remains the same. Many thanks!
Have you tried
perch_pages_next_page()
?This shows the parent page, not the second level. And if I add
'levels' => 1
it still does not works...
The
level
option controls the number of levels to show.Does adding in the
from-path
option step you down a level?So, the following shows the parent page:
and this shows all of subpages:
Maybe my from-path is wrong? The navigation structure in Perch looks like this:
and so on
I don't see why texting for the first item only wouldn't work. Can you should me what you did with your template when that failed?
I agree, the solution should be perch_pages_next_page(). I think my from-path is wrong, because even without it I have the parent page as output. How does from-path have to be? The parent page of subpages is news.php, the path of a subpage is eg. news1.php. Is this correct?
Are the news items not within a subfolder?
Yes they are. The from-path inside perch_pages_next_page() does not seem to work. It always outputs a link at the same level and not inside the news-folder. Sorry, Drew this seems to be strange...
No, it's
perch_pages_navigation()
that you want with the template modification I suggested.But to link to the first element in the subfolder /news I still think perch_pages_next_page() would be fine. Otherwise I get the whole navigation. This could only be the solution if we have a condition to just show the first element. But as you wrote in an answer before count is not suppported... Would there be another way to achieve this?
If you think
perch_pages_next_page()
will be fine then you stick with that.I think it sounds like you're very close with
perch_pages_navigation()
and just need to modify the template, but what do I know.Thank you very much for your help anyway, Drew! I keep on finding the solution...