forming links with titles and alt text
#1
Posted 05 June 2009 - 08:48 PM
Is there a way to get to the database fields of the target so they can be used in the link?
Using [*pagetitle*] returns the current page, not the one that is being targeted.
Example using the above, is there a way to get pagetitle and longtitle of visitors so the link could be formed like this:
<a href="[~visitors~]" alt="[*visitor's pagetitle*]" title="Go to [*visitor's pagetitle*]">visitors</a>
#2
Posted 05 June 2009 - 09:58 PM
Something like:
Snippet: link_snippet
$page=isset($page) ? $page : $etomite->documentIdentifier; $url=$etomite->makeURL($page,'',''); $pageInfo=$etomite->getPageInfo($page, $active=1, $fields='id, pagetitle, alias, longtitle'); $text=isset($text) ? $text : 'default text'; $output= "<a href=\"'.$pageInfo['alias'].'\" alt=\"'.$pageInfo['longtitle'].'\" title=\"'.$pageInfo['pagetitle'].'\">'.$text.'</a>"; return $output;
Then call this in the page where you want the link:
[!link_snippet?page=24&text=visitors!]
will display the required info (not tested).
#3
Posted 06 June 2009 - 10:26 PM
That is, unless you want automatically generated link information for some reason.
If so, the link being generated must be RELATIVE to any given starting variable. For example- relative to the page you are currently on: a parent, a child, or the ID +5 or the alias less the first 3 letters in the name etc, or relative to the time of the day or day of the week or a session cookie value.
Most of the many navigation snippets create dynamic links like this and may be appropriate for what you are doing if you need more than just a hard-coded link.
#4
Posted 08 June 2009 - 05:08 PM
After more thought on this, it makes we wonder why you would do this and not just hard-code the link in instead of using a snippet and targeting the page in the snippet call. It would be far easier, quicker and cleaner to just manually put the link to the page in your template and type in the pagetitle and longtitle of the target.
That is, unless you want automatically generated link information for some reason.
If so, the link being generated must be RELATIVE to any given starting variable. For example- relative to the page you are currently on: a parent, a child, or the ID +5 or the alias less the first 3 letters in the name etc, or relative to the time of the day or day of the week or a session cookie value.
Most of the many navigation snippets create dynamic links like this and may be appropriate for what you are doing if you need more than just a hard-coded link.
if you use [~23~] where 23 is the ID of the page you're linking to, then you don't have to worry about a possible page alias change down the road. When using SEF URL's this method will generate agood clean link that looks like '/visitors.html" or whatever.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











