Created
May 24, 2012 09:08
-
-
Save moonbeetle/2780371 to your computer and use it in GitHub Desktop.
Stash example (ExpressionEngine)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{!-- PART 1 : Put the code below in the beginning of your template --} | |
{exp:stash:set parse_tags="yes" replace="no" refresh="1440"} | |
{!-- Stashing Channel Entries data example --} | |
{!-- (use as many custom fields form the channel as you need) --} | |
{exp:channel:entries channel="ENTERCHANNENAMEHERE" limit="1" disable="member_data|pagination|categories"} | |
{stash:page_title}{title}{/stash:page_title} | |
{/exp:channel:entries} | |
{!-- Stashing a custom value example --} | |
{stash:my_custom_value}Hello world!{/stash:my_custom_value} | |
{!-- Stashing a custom value example mixed with some markup --} | |
{stash:my_custom_value_html} | |
<h2>Hello world wrapped in a Header2 tag!</h2> | |
{/stash:my_custom_value_html} | |
{/exp:stash:set} | |
{!-- End PART 1 --} | |
{!-- Now, let's output some stashed data... --} | |
<html> | |
<head> | |
<title>{exp:stash:get name="page_title"}</title> | |
</head> | |
<body> | |
<h1>{exp:stash:get name="page_title"}</h1> | |
{exp:stash:get name="my_custom_value"} | |
{exp:stash:get name="my_custom_value_html"} | |
<p>Notice that the stashed page title is reused twice, in the title tag of the HTML and with the body part of the HTML.</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment