Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Hello,
I searched for solutions for this but all the ones i found are for more complicated setups like these:
-----------------------------------------------------------------------------------
http://www.couchcms.com/forum/viewtopic.php?f=4&t=8496&p=15995&hilit=current+page+navigation#p15995
http://www.couchcms.com/forum/viewtopic.php?f=4&t=6934&p=8820&hilit=current+page+nav#p8820
------------------------------------------------------------------------------------

PROBLEM:
I just need to find a way to identify when a main directory is being viewed
And or
one of it's sub-directories is being viewed so i can style the link in the navigation accordingly.

MY SETUP:
I can easily do an "if" condition to add the html id to one of the main current directory links. But what i don't know how to do is how to detect (a sub directory) to highlight its "Parent Directory link" in the navigation.

I have a simple website with 4 MAIN directories, the links are in an HTML snippet and embedded in the site's header. The website has many sub-directories and when a user is in any of them only it's parent link has to be "styled" with an html id. (all the html pages are named index.html, so identifying the directory with the name i believe is out of the question)
Is there maybe a way to see if the current page's link a user is on contains part of the main directories link (url)?
Hi,

It is not clear from your query if the directories/sub-directories you mention are the actual 'physical' folders or are they the 'virtual' folders of Couch (http://docs.couchcms.com/concepts/using-folders.html)?

Could you please clarify?

A 'tree-view' of a portion of your website will also help.

Thanks.
KK wrote: Hi,
Could you please clarify?

A 'tree-view' of a portion of your website will also help.

Thanks.


Hey KK, thanks alot for trying to understand haha i guess i really didn't explain very well, let me try again.

I added the Tree view of my site as an image. And so as you can see each "directory" is an actual physical folder on the server. Each directory also contains either an index.html or index.php file (which of course is what a user sees when they are there). Any Sub-directory is also contained within a directory, meaning there are folders within folders.
Untitled-1.gif
Untitled-1.gif (13.9 KiB) Viewed 2807 times


I basically have been trying to find a way to "detect" which of the main folders the user is viewing or in. Just like the very first part in the tutorial here: http://docs.couchcms.com/tutorials/port ... -ends.html

The problem is that in the tutorial we use the template's name to identify which part of Aurelius we're looking at (to style one of the links on the header accordingly). The problem with my setup is that i have sub and sub-sub-directories and all the files are named index. So i can't just detect the page's name. I thought maybe i could use the page's link (k_page_link).

Say for example i wanted to know if a user was looking at a page somewhere within the Tutorials section, i would have to do something like:
(If the page link contains http://localhost/tutorials/

Translated into code all i can come up with is:
<cms:if k_page_link = 'http://localhost/tutorials/'> id='current-page' </cms:if>
But that doesn't work because the link would have to be exactly the same no more no less.

And so that's where i'm at, i'm really sorry if this is a newbie question, i'm still working on my first CouchCMS setup, i simply don't know what page variable may be able to help me identify a user's location within the folder structure.
Hi, @OscarG. Thanks for making desc clear.
Use <cms:dump_all /> to see available variables :) Next, since you have done some job to put php templates in physical directories manually, there is no big deal to create current name and parent name manually too somewhere on top of each physical file.
Code: Select all
<cms:set my_current_page = 'Step 2' scope='global' />
<cms:set my_currentpage_parents = 'Tutorials | Main Tutorial' scope='global' />

The above variables will be available to you anywhere inside the template you have them set in.

Each directory also contains either an index.html or index.php file. Any Sub-directory is also contained within a directory, meaning there are folders within folders.

Anyways, the problem with your setup is that it doesn't actually need a CMS to manage menu - you can manually copy-paste it to all your files and manually place correct highlighting ID to necessary levels and menu items. Pretty weird, and would recommend to redo the whole thing, according to the Aurelius Tutorial.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
trendoman wrote: The above variables will be available to you anywhere inside the template you have them set in.


Ohhh ok, right! I can set a variable for each of the four main directories and add them in all the pages and then just check if that variable is available, and if it is i can display the correct highlight because only one of the four would be available.

My intention is to make editing the header of the whole website easy by just editing it in one place, because it's not always going to be a small website. In this case i would only have to edit the header html snippet.

Thank you so much Trendoman, that really helped. You made my day! :D
5 posts Page 1 of 1