0

I'm using stash to fuel many parts of a site I am building. I successfully have it working to print certain parts of the page title to the tag of the page, but I want to include entry titles on pages where that is applicable. Here is my code setup for a given scenario:
This is my "main" template

    {embed="_layout/events"}
{preload_replace:the_channel="events"}
{exp:stash:set_value name="title" value="Events"}    

<!-- ???USE STASH APPEND FOR ENTRY PAGE TITLE???? -->

{exp:stash:set name="listing-content"}
<h1>Events</h1>
<p class="events-desc">{exp:low_variables:single var="lv_events_summary"}</p>

<div class="w-row">
    {exp:channel:entries 
        channel="{the_channel}"
        disable="categories|category_fields|member_data|pagination" 
        limit="3" 
        show_future_entries="yes"
        sort="desc"
        status="Open|Home"
        }
    <div class="w-col w-col-4 w-col-medium-4">
        <a class="_97 card w-inline-block" href="/events/{url_title}">
            <h4>{title}</h4>
            {exp:channel_images:images entry_id="{entry_id}"}
            <img class="event-cover" src="{image:url:card}" alt="{site_name} {seo}">
            {/exp:channel_images:images}
            {exp:chopper}{summary}{/exp:chopper}
        </a>
    </div>
    {/exp:channel:entries}
</div>
{/exp:stash:set}



{exp:stash:set name="entry-content" parse_tags="yes"}
{exp:channel:entries
    channel="{the_channel}" 
    disable="categories|category_fields|member_data|pagination" 
    limit="1"
    show_future_entries="yes"
    status="Open|Home" 
    url_title="{last_segment}"
    }
{exp:stash:set_value name="page_title" parse_tags="yes" parse_depth="2" name="page_title"}
<h1>{title}</h1>

<div class="w-row">
        <div class="w-col w-col-9 w-col-stack">
            <blockquote>{summary}</blockquote>
        </div>


    </div>

    <!-- /content -->

    <div class="content-col-2 w-col w-col-3 w-col-stack">

<!-- sidebar -->

    </div>
    {/exp:channel:entries}
</div>

{/exp:stash:set}

This is my {embed="_layout/events"} template

{p_head}
<div class='content'>

    {exp:switchee variable='{segment_1}/{segment_2}' parse='inward'}

    {case value='{segment_1}/'}
    {exp:stash:get name='listing-content'}
    {/case}

    {case default='Yes'}
    {exp:stash:get name='entry-content'}
    {exp:stash:get name='sidebar'}
    {/case}

    {/exp:switchee}

</div>

{p_footer}

And finally, here is my {p_head} file which is trying to reference the stashed element called "page_title" which is in the entry section of the main template:

    <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{exp:stash:get name="title"}{exp:stash:get name="page_title" proces="end"} | {site_name}</title>

The stash:get for title works just fine, but the stash:get for page_title comes up blank. Any suggestions? Thanks!!!

0

There is a lot of noise in your examples, but it looks like you are simply not including a value in the set_value entry (and you have name=... twice).

You probably want something like this...

{exp:stash:set_value name="page_title" value="{title}" parse="inward"}

The parse='inward' needed to make sure the tag in value= is parsed before it gets used to set the value.

HTH

| improve this answer | |
  • thanks. I've updated the set_value line to this {exp:stash:set_value name="page_title" parse_tags="yes" parse_depth="2" value="{title}" parse="inward"} but I'm still not getting the stash:get in my partial {exp:stash:get name="page_title" process="end"} (fixed the misspelled process). Now I get this, which is progress, but not an entry title <title>{14e2f2245fc6b02834ca32c29099610a2014288736}</title> what the heck is that number?!? – soire Jun 28 '17 at 16:16
  • No idea. Have you tried putting in simple text rather than a tag? Have you tried a different tag to {title}? What happens if you do? – JCOGS Design Jun 28 '17 at 18:32
  • Yes, I've tried other tags and even plain text. I still get a string of numbers...and when you refresh, the numbers change...same length of a string...baffled... – soire Jun 28 '17 at 18:49
  • Stash is weird sometimes. Best thing to do next probably is contact Mark Croxton and ask him... he's pretty good at answering questions via either EECMS Slack or the Devot.ee forum (devot-ee.com/add-ons/support/stash/viewforum/1484) – JCOGS Design Jun 29 '17 at 0:14
  • If you are only using the {title} tag in your set_value entry you probably don't need to set the parse_depth="2" in your tag - I included in the example given simply because you had it there in the original. But you'll get the {title} value without it. Not sure if it will fix your problem, but worth a try (and good housekeeping etc.). – JCOGS Design Jun 29 '17 at 12:14
0

The first solution is working on my end. (by jcogs.eecms) I still can't comment, so.. i'm just leaving this here :)

  • EE3.5.7
  • Stash 3.0.5
  • switchee 3.0.0
| improve this answer | |
  • You should mark it as the answer. – Romans-8---31-39 Jul 10 '17 at 13:46
  • Why would it be marked as the answer when it is still not working? I've contacted Mark Croxton about this and even he hasn't been able to solve... – soire Jul 10 '17 at 16:12
0

Here's what works for us, I'm showing the important bits. We're using MVVM so it may not be entirely applicable to you, but hopefully there's some useful in this.

In the Layout:

{stash:embed:global_template_chunks:global_html_head process="start"}

In global_template_chunks/global_html_head:

<title>{stash:page_title} | {site_name}</title>

In your template:

{!-- Set page Meta Data --}
{exp:stash:context name="{segment_1}-{segment_2}"} {!-- Sets the Stash @ symbol --}
{exp:stash:set_value name="url_title" value="{segment_1}-{segment_2}"}
{stash:embed:global_template_chunks:set_meta}
{!-- Set basic page details --}
{stash:embed:global_template_chunks:page_intro process="inline"}

In global_template_chunks/set_meta:

{!-- GENERAL --}
{!-- To override just a few values like page_title set them after calling this file --}
{exp:stash:set name="page_title" trim="yes"}
{if "{exp:surgeeo:title url_title='{stash:url_title}'}" != ""}
{exp:surgeeo:title url_title='{stash:url_title}'}
{if:else}{exp:stash:get_list name="page:{stash:url_title}" scope="site" trim="yes"}{title}{/exp:stash:get_list}{/if}
{/exp:stash:set}

In global_template_chunks/page_standard:

{exp:stash:set_list name="page" parse_tags="yes" context="@"}
{exp:channel:entries channel="standard_pages" dynamic="no" url_title="{stash:url_title}" disable="categories|member_data|pagination" limit="1"} 
    {stash:title}{title}{/stash:title}
    {stash:entry_id}{entry_id}{/stash:entry_id}        
    {stash:body}{standard_body}{/stash:body}
    {stash:sharing_image}{/stash:sharing_image}
    {!-- Call to Action --}
    {standard_call_to_action limit="1"}
        {stash:cta_link}{standard_call_to_action:link}{/stash:cta_link}
        {stash:cta_text}{standard_call_to_action:text}{/stash:cta_text}
    {/standard_call_to_action}

    {if no_results}{redirect="404"}{/if}

{/exp:channel:entries}
{/exp:stash:set_list}    
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.