using page description for internal links

Permalink Browser Info Environment
Hi Guys,
is it possible to use using page description for internal links, not the link itself?

Regards

Torsten

Type: Discussion
Status: New
tsilbermann
View Replies: View Best Answer
jordanlev replied on at Permalink Reply
jordanlev
Hey,
Just one guy here. Yes, this is fairly easy to do. Just edit your block's view.php file and find the code that grabs the link text -- should look something like this:
$link_text = empty($field_6_link_text) ? $link_url : htmlentities($field_6_link_text, ENT_QUOTES, APP_CHARSET);

...and change it to something this:
$link_text = htmlentities(Page::getByID($field_6_link_cID)->getCollectionDescription(), ENT_QUOTES, APP_CHARSET);


(NOTE that you'll probably need to change the field number in the sample code I pasted above, depending on how your block is built).

-Jordan
tsilbermann replied on at Permalink Reply
tsilbermann
Hey Jordan - so much stuff and just one guy behind? Wow! ;-)
thanks for the fast and working reply but I think I asked wrong (but I'm sure I need that as well next time^^).
I need the pretty URLs (like "Hello World"), not the long ones (like "http://www.xyz/blog/hello-world").

Thanks

Torsten
jordanlev replied on at Permalink Reply
jordanlev
I'm sorry, but I do not understand what you are asking. Can you take a screenshot of how your block is now, then explain how exactly you want it to be different?

-Jordan
tsilbermann replied on at Permalink Reply
tsilbermann
Hey Jordan
the Block shows the whole URL of the internal Link (the whole path/ Canonical URL). I just need the Name of the Page displayed. Do you understand or need a screenshot?
Regards
Torsten
jordanlev replied on at Permalink Best Answer Reply
jordanlev
The code I posted above should be showing the description of the page (which is what you asked for in your first question), but perhaps your descriptions are empty so it's showing the URL instead?

But it sounds like what you really want is the page name, not the description. So try this code instead:
$link_text = htmlentities(Page::getByID($field_6_link_cID)->getCollectionName(), ENT_QUOTES, APP_CHARSET);


If that still doesn't work, please ZIP up your block directory and post it here so I can look at your code.

-Jordan
tsilbermann replied on at Permalink Reply
tsilbermann
You are right - page name, not description. Works well - thanks a lot.
Torsten

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.