[TYPO3] anchor tags

Christopher Torgalson bedlamhotel at gmail.com
Thu Dec 13 15:18:06 CET 2007


Hi,

Cate & Peter wrote:
> Hi again,
> 
> Still working out these typolinks for anchors ...
> 
> Christopher wrote: 
> 
> ### Typoscript:
> ###
> lib.skipnavigation = HTML
> lib.skipnavigation {
> 	### The link text:
> 	###
> 	value = Skip to content
> 	value {
> 		typolink {
> 			### Create a link to the current page:
> 			###
> 			parameter.data = field:uid
> 
> 			### Link to a specific anchor:
> 			###
> 			section = content
> 		}
> 	}
> }
> 
> Cate:
> I pasted the above TS into the template, and mapped lib.skipnavigation, but
> nothing was rendered from it - no text, no link.  I have no idea if I
> completely misunderstood Christopher... I don't know what I don't know, so
> to speak.
> 
> Anyhow, after much fiddling, I did get the text showing, but the only way I
> could get a link was by wrapping an <a href> tag around - if there is no
> wrap, there is no link, which seemed very wrong to me...
> 
> 
> This is what I have done...
> 
> lib.skipnavigation = CONTENT
> lib.skipnavigation{
> table = tx_drwiki_pages
>   select {
>     pidInList = this
>     selectFields = pid, keyword
>     
>  }
>   renderObj = TEXT
>   renderObj {
>     required=1
>     
>     # Displays the keyword inside the <li/> tags
>     value = Skiplink to content
>     
>     # Inner wrap around individual rows
>     wrap=<li class="access_links">|</li>
>     
>     # Wraps the keyword with a link to the correct page
>     typolink {
>       # Links to the page that the wiki keyword is found on
>       parameter.data = field:pid
>      
>       # Adds the keyword to the query string 
>       additionalParams.wrap = &tx_drwiki_pi1[keyword]=|
>       additionalParams.data = field:keyword
> 
>       #add the anchor
>       section = Content
> 
>     }
>   }
> 
> }
> 
> Which works ... except...
> 
> It wants to make links for every wikipage, and list them all on every page
> as  multiple "skiplink to content" links.
> 
> Is there not some way to retrieve the exact url as it appears in a page,
> including the extra parameters, and plug it into the code to just add the
> anchor?  Something like $GLOBALS["TSFE"]?


I just tested the TS I sent you to double-check, and it works just as 
intended. The *only* thing that could make that TS fail is if somehow 
there is no value for the 'field:uid' bit--but even then, the thing is 
an ordinary HTML cObject, so you should still see the text--which is 
what it sounds like you're describing.

In any case, it sounds like you need the parameters from the drwiki 
extension (I've never used it, maybe it shows records always on a single 
page like tt_news?) If so, then this should work:


lib.skipnavigation = HTML
lib.skipnavigation {
	// The link text:
	value = Skip navigation
	value {
		typolink {
			// Get the id of the current page:
			parameter.data = page:uid
	
			// Add whatever is in the query string:
			addQueryString = 1
			addQueryString {
				// Account for the fact that RealURL etc may have manipulated the 
query string:
				method = GET
			}
	
			// Link to the appropriate section on the page:
			section = content
		}
	}
}


If you want a bit of the theory behind this ( hint, hint :-) ), check 
out http://www.typo3apprentice.com/samples/tv-print-link/



-- 
Christopher Torgalson / bedlamhotel at gmail.com


More information about the TYPO3-english mailing list