Jump to content


[Snippet] AliasChunk


  • You cannot reply to this topic
1 reply to this topic

#1 Dean

    Loves Etomite Forums!

  • Admin
  • 4,758 posts
  • Gender:Male

Posted 16 April 2007 - 08:00 AM

Snippet Migrated from Snippet Library - The Poster (ME) takes no Credit for the snippet, and cannot help with issues with it.

File Name: AliasChunk
File Submitter: Dean
File Submitted: 16 Apr 2007
File Category: Miscellaneous

This is a simple snippet I wrote to look for and output alias-specific chunks, and if nothing is found, it returns a chunk with the base name passed in the variable `nameOfChunk`. Alias-specific chunks follow the naming convention `alias`-`nameOfChunk`.

Click here to download this file

#2 PaulD

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 398 posts
  • Gender:Male

Posted 10 July 2009 - 04:30 PM

I love this snippet. Only 8 lines of code but sooooooooooo powerful and neat!

I usually use this to add javascript calls and css calls to pages that require extra stuff in the header. Here are some more detailed instructions.

1. Add the snippet
Download snippet and add it to your site calling the snippet 'AliasChunk'.

2. Call the snippet
In the head section of your template (although you can use this anywhere) put a call something like this:
[!AliasChunk?nameOfChunk=header!]

3. Create default content chunk
Add a chunk called 'header' with some default info in it. For me this is usually blank by default so my header chunk contains something like:
<!-- Nothing inserted by AliasChunk by default -->

4. Create page specific chunk
Now for my homepage, which has an alias of 'home', I want some extra bits added to the header.
So now all I have to do is add a chunk called 'home-header', for testing I simply insert a different comment.
<!-- content added to alias 'home' by AliasChunk acting on a chunk name of 'header' -->

Now when I load the home page, alias chunk does all the work, adding in the right chunk of extra code. Note that all other pages on the site still have the default message. By adding more chunks I can add different info into the header of any page I choose. This simple snippet does a very powerful thing. And I can call it as many times as I like on a page.

Hope this helps someone.

Paul.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users