Want to get description text in the link

Permalink
I want the page description below the every link of navigation

I have use the code below

$c = Page::getCurrentPage();
$strDesc = $c->getCollectionDescription();


and declare the variable in link as

<a class="nav-selected nav-path-selected" ' . $target . ' href="' . $pageLink . '">' . $ni->getName() . '<span>'. $strDesc .'</span></a>


but there is problem it brings the only current page description to all links.

can anyone help me

View Replies: View Best Answer
citytech2 replied on at Permalink Reply
citytech2
You are assigning an instance of the current page into $c.
$c = Page::getCurrentPage();

And call the description of that instance
$strDesc = $c->getCollectionDescription();


I think you are intelligent enough to understand that. :)

Citytech
manpreet replied on at Permalink Reply
Sorry, i am new to PHP. I am not getting what is the problem.

Thanks
citytech2 replied on at Permalink Best Answer Reply
citytech2
The code should be like this:

$desc = $_c->getCollectionDescription();
         if ($c->getCollectionID() == $_c->getCollectionID()) { 
            echo('<li class="nav-selected nav-path-selected"><a class="nav-selected nav-path-selected" ' . $target . ' href="' . $pageLink . '">' . $ni->getName() ." <br />". $desc .'</a>');
         } elseif ( in_array($_c->getCollectionID(),$selectedPathCIDs) && ($_c->getCollectionID() != HOME_CID) ) {
            echo('<li class="nav-path-selected"><a class="nav-path-selected" href="' . $pageLink . '" ' . $target . '>' . $ni->getName() . " <br />". $desc .'</a>');
         } else {
            echo('<li><a href="' . $pageLink . '" ' . $target . ' >' . $ni->getName() ." <br />". $desc .'</a>');
         }
manpreet replied on at Permalink Reply
Thanks a lot :)
citytech2 replied on at Permalink Reply
citytech2
Mark this as best answer as it will help others to find the solution.

Citytech
marticps replied on at Permalink Reply
marticps
Hi,
Just done something similar in my website, but it does not work at all:
http://www.concrete5.org/community/forums/customizing_c5/do-single-...

Hope you can help me.
citytech2 replied on at Permalink Reply
citytech2
Which version of C5 you are using? It seems to be an earlier version as per the code.

Citytech
marticps replied on at Permalink Reply
marticps
I am running 5.5.2.1
citytech2 replied on at Permalink Reply
citytech2
Then the code should be like above, but it isn't. You can try to copy the above code & replace it with your once.
Note: Please have a backup of that view.php file first.

Citytech
marticps replied on at Permalink Reply
marticps
I modified the code to this:
$desc = $_c->getCollectionDescription();
         if ($c->getCollectionID() == $_c->getCollectionID()) { 
            echo('<li class="nav-selected nav-path-selected '.$isFirstClass.'"><a class="nav-selected nav-path-selected" ' . $target . ' href="' . $pageLink . '"><span class="nnn">' . $ni->getName() . '</span><span class="desc">' .  $desc . '</span></a>');
         } elseif ( in_array($_c->getCollectionID(),$selectedPathCIDs) && ($_c->getCollectionID() != HOME_CID) ) {
            echo('<li class="nav-path-selected '.$isFirstClass.'"><a class="nav-path-selected" href="' . $pageLink . '" ' . $target . '><span class="nnn">' . $ni->getName() . '</span><span class="desc">' .  $desc . '</span></a>');
         } else {
            echo('<li class="'.$isFirstClass.'"><a href="' . $pageLink . '" ' . $target . ' ><span class="nnn">' . $ni->getName() . '</span><span class="desc">' .  $desc . '</span></a>');
         }


but I get this error:

( ! ) Warning: in_array() expects parameter 2 to be array, null given in C:\wamp\www\ART-RENTING\c5\blocks\autonav\templates\menu_artelea.php on line 44

(All descriptions are showing except Profile's one, that is still not showing).

Thanks for your help
citytech2 replied on at Permalink Reply
citytech2
give me the link of your site.
marticps replied on at Permalink Reply
marticps
It is in localhost, but I think that the problem is with the description attribute in the profile single page, not about the code... Maybe I have to call it in other way?
citytech2 replied on at Permalink Reply
citytech2
Sorry Bro, I have no idea. Maybe some other member can help you.

Citytech
marticps replied on at Permalink Reply
marticps
No problem,
Thank you very much