[Catalyst] Sharing code / Feedback request: TT macro for uri_for([current uri]); same page links

apv apv at sedition.com
Sun Oct 22 03:46:21 CEST 2006


Something common that irritates me on sites is links on a page which  
point to the page they're on.

Say you're viewing "/" (home) and there are links which go to "/" --  
not sensible. The following macro, "link," disables them with JS  
(makes more sense semantically than not using <a> tags) and adds a  
CSS class so they can be made to look different, or disappear  
altogether.

Does it look like a good way to do it? Improvements?

[% MACRO link(path,title) BLOCK %]
[% FILTER trim %]
[% IF Catalyst.uri_for("/", Catalyst.request.path) == Catalyst.uri_for 
(path)  %]
<a title="The current page" class="current" href="javascript:void 
(0);">[% title | html_entity %]</a>
[% ELSE  %]
<a title="[% title | truncate(50,"&hellip;") | html_entity %]"  
href="[% Catalyst.uri_for(path) %]">[% title | html_entity %]</a>
[% END %]
[% END %]
[% END %]


-Ashley



More information about the Catalyst mailing list