Created
August 28, 2012 19:12
-
-
Save timkelty/3502699 to your computer and use it in GitHub Desktop.
Using Stash for parsing "needles" out of content fields (similar to techniques using Copee Pastee/LG Replace)
This file contains hidden or 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
{!-- embed page template --} | |
{embed="site/_page" | |
hide_site_title="{embed:hide_site_title}" | |
body_class="p-default" | |
} | |
{!-- get channel data --} | |
{exp:channel:entries | |
limit="1" | |
entry_id="{embed:entry_id}" | |
dynamic="{embed:dynamic}" | |
require_entry="{if embed:dynamic != 'no'}yes{/if}" | |
disable="categories|category_fields|member_data|pagination|trackbacks" | |
} | |
{if no_results}{redirect="404"}{/if} | |
{!-- set needles for inline wygwam replacement --} | |
{!-- matrix --} | |
{cf_page_resources} | |
{exp:stash:set | |
name="resource:{row_count}" | |
type="snippet" | |
} | |
{!-- playa --} | |
{cell_resource} | |
{stash:embed | |
name="inline_resource" | |
process="start" | |
} | |
{/cell_resource} | |
{/exp:stash:set} | |
{/cf_page_resources} | |
{!-- set stashes --} | |
{exp:stash:set name="entry_id"}{entry_id}{/exp:stash:set} | |
{exp:stash:set name="title"}{title}{/exp:stash:set} | |
{exp:stash:set name="content"} | |
<h1>{title}</h1> | |
<div class="content-inner"> | |
{if segment_1 != "search"} | |
<div class="group"> | |
<div class="content-1 append-gutter"> | |
{exp:stash:parse process="end"}{cf_page_body}{/exp:stash:parse} | |
{exp:stash:get name="after_content"} | |
</div> | |
<div class="content-2"> | |
{if "{structure:child_ids}" || "{structure:parent:entry_id}" != "1"} | |
<h2>More About {if "{structure:top:title}" == "About"}Telx{if:else}{structure:top:title}{/if}</h2> | |
{exp:structure:nav | |
start_from="/{segment_1}" | |
css_class="sub-nav" | |
} | |
{/if} | |
{if cf_page_resource} | |
{embed="site/_resources" entry_ids="{exp:playa:child_ids field='cf_page_resource'}"} | |
{/if} | |
{if segment_1 != "about"} | |
<h2>Interconnection Products</h2> | |
{embed="products/_nav"} | |
{/if} | |
<h2>Our World Class Data Centers</h2> | |
<p>Learn more about our data centers. Strategically located in nine Tier 1 markets. <a href="/data-centers/">Learn More »</a></p> | |
{embed="data-centers/_medium-map"} | |
<h2>Contact Us</h2> | |
<p>Please contact our sales team to find out more about...</p> | |
<ul class="contact-methods"> | |
<li class="email"><a href="http://map.telx.com/Web-Lead-Testing.html" class="fancy-iframe">Email</a></li> | |
<li class="chat"><a href="">Chat</a></li> | |
</ul> | |
</div> | |
</div> | |
{/if} | |
{exp:stash:get name="after_body"} | |
</div> | |
{/exp:stash:set} | |
{/exp:channel:entries} |
This file contains hidden or 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
<div class="inline-vid"> | |
<a href="#page-video" class="fancylink"> | |
<div class="mejs-overlay-button"></div> | |
{exp:ce_img:single | |
src="{cf_video_img}" | |
width="260" | |
height="150" | |
crop="yes|center,center" | |
} | |
</a> | |
{if cf_video_caption} | |
<div class="caption"> | |
<div class="caption-inner">{cf_video_caption}</div> | |
</div> | |
{/if} | |
</div> | |
<div style="display: none"> | |
<div id="page-video" class="external-vid"> | |
{if cf_video_link} | |
{cf_video_link} | |
{if:elseif cf_video_mp4 || cf_video_webm} | |
<video controls="controls"> | |
{if cf_video_mp4}<source src="{cf_video_mp4}" type="video/mp4" />{/if} | |
{if cf_video_webm}<source src="{cf_video_webm}" type="video/webm" />{/if} | |
<object type="application/x-shockwave-flash" data="/assets/js/lib/mediaelement/build/flashmediaelement.swf"> | |
<param name="movie" value="/assets/js/lib/mediaelement/build/flashmediaelement.swf"> | |
<param name="allowFullScreen" value="true"> | |
<param name="wmode" value="transparent"> | |
<param name="flashVars" value="config={'playlist':['{cf_video_img}',{'url':'{cf_video_mp4}','autoPlay':false}]}"> | |
<p>Upgrade your browser to watch the video.</p> | |
</object> | |
</video> | |
{/if} | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Concept
You have a Matrix field with each row defining a "needle" of content. Some use Copee Pastee to help users copy/paste the needles. The other columns are whatever is necessary for your content. In this example, a Playa cell is used.
In a content field (textarea, Wygwam, Rich Text Editor), users can paste in {the_name_of_your_needle:row_number} wherever they like (e.g. {resource:4}.
In the template, Stash powers the parsing of these needles, and your content is...parsed.
Similar result to techniques using NSM transplant/LG Replace