Alter colour of autonav item based on page attribute

Permalink 1 user found helpful
Hi,

I'd like to be able to set a page as 'greyed out' so that it will appear in an autonav block in a different colour. This is so that the user knows that the page will be available but is currently not active (rather than the user getting frustrated going to lots of 'under construction' pages). Can I set up a custom page attribute to do this then add some code to the autonav block?

Thanks,
Richard

 
ScottSandbakken replied on at Permalink Best Answer Reply
ScottSandbakken
Create a text page attribute called "Nav Item Class" with the handle "nav_item_class". You will need to add the text "inactive" to this field on all the pages that you want to be greyed out.

In [root]\concrete\blocks\autonav\view.php file to the [root]\blocks\autonav\templates\greyed_inactive\ folder (you will need to create this folder). Then, create a view.css file in the folder you just created.

Next, open the file you just copied and find the line that adds the Nav Item Class attribute to the classes array (about line 88).

Remove the /* before the declaration and the */ after it so it looks like this.

if (!empty($ni->attrClass)) {
   //class that can be set by end-user via the 'nav_item_class' custom page attribute
   $classes[] = $ni->attrClass;
   }


Now open the view.css file you created, and add this

ul.nav a.inactive {
   color:#cacaca;
}


NOTE: I am assuming that you are using Concrete5.6 or higher.
ScottSandbakken replied on at Permalink Reply
ScottSandbakken
Were you able to get this to work?
rpain replied on at Permalink Reply
Hi all - I hope you had a lovely Christmas and new year.

Yes we did get this to work in the end. I forwarded your suggestion to the guy who did the work and I believe it was helpful to him so thanks - really appreciated.

Best wishes,
Richard