# Question
Title: why is my template partials w/ stash approach slower than the ordinary one?
I've used the template partials method to "uprade" one of my site's template to this approach.

What I don't understand is, that although my stash template only has one single embed vs. 5 embeds, it's still performing considerably slower and uses more queries!

the "normal" templates uses about 93 to 95 queries and renders in around 0.5 seconds

the new approach takes from 95 to 98 queries and renders usually in about 1seconds.

you can really feel the difference in speed and rendering.

I am really new to template partials and maybe one of the pro's could look if I am doing something wrong?!

so here's my standard template - before stash (it's a structure powered site)

```
{gv_doctype}
{preload_replace:pre_prefix="static"}
{if in_group(1)}{preload_replace:pre_status="open|Draft"}{/if}{preload_replace:pre_status="open"}
{exp:channel:entries channel="ch_static"  limit="1" status="{pre_status}" disable="categories|member_data|pagination"}
{embed="_includes/_head" emb_entry_id="{entry_id}"}
{sp_color}
</head>
<body id="{segment_1}">

{embed="_includes/_admin"}
{gv_start}

    {embed="_includes/_header"}
    <section id="content_container">
        {embed="_includes/_navigation" emb_status="{pre_status}"}

        {exp:nsm_transplant:body}
            {cf_static_block_matrix}
                <article class="content_block{if status == 'Draft'} logged_in{/if}">
                    {if title}<h1>{title}</h1>{/if}
                    {if media AND text}
                        <div class="image">
                            {media}
                        </div>
                        <div class="text">
                            {text}
                        </div>
                    {if:else}
                        {text}{media}
                    {/if}
                </article><!-- end content_block -->
            {/cf_static_block_matrix}
            {!--

                video, slideshow and file replacement with {pre_prefix}

            --}
            {sp_static_img_replacement}
            {sp_video_replacement}
            {sp_file_replacement}
        {/exp:nsm_transplant:body}
        {sp_edit}
    </section><!-- end #content_container -->
    {embed="_includes/_footer"}

{gv_before_end}
{embed="_includes/_end"}

<script type="text/javascript">
    jQuery(function($){
        $.supersized({
            //Background image
            slides  :  [ { image : '{cf_{pre_prefix}_background limit="1"}{url:max_size}{/cf_{pre_prefix}_background}' } ]
        });
    });
</script>

{/exp:channel:entries}
{gv_end}

```

and here's my new 2 templates:

the wrapper template:

```
<!DOCTYPE html>
<html lang="de">
<head>

    <meta charset="utf-8" />
    {exp:seo_lite entry_id="{exp:stash:get name='entry_id'}" parse="inward"}
    <meta property="og:site_name" content="..."/>
    <meta property="og:title" content="{exp:stash:get name='title'}" />
    {sp_global_head}
    {exp:stash:get name='color'}

</head>
<body id="{segment_1}">

{embed="_includes/_admin"}

{gv_start}

    <header id="header">
        <h1 id="logo"><a href="{path=''}" class="hide-text">...</a></h1>
    </header>

    <section id="content_container">
        <!-- main navigation -->
        <nav id="main_nav">
            {exp:structure:nav start_from="/" max_depth="1" status="{exp:stash:get name='status'}" css_id="none" parse="inward"}
        </nav><!-- end main_nav -->
        {exp:stash:get name='main_content'}
    </section><!-- end #content_container -->

    <footer id="footer">
        <p>...</p>
    </footer><!-- end #footer -->

{gv_before_end}
{embed="_includes/_end"}

<script type="text/javascript">
    jQuery(function($){
        $.supersized({
            //Background image
            slides  :  [ { image : '{exp:stash:get name='background_image'}' } ]
        });
    });
</script>
{gv_end}

```

the other one:

```
{!--

    View Model Static

--}
{embed="_wrapper/_standard"}

{preload_replace:pre_prefix="static"}
{if in_group(1)}{preload_replace:pre_status="open|Draft"}{/if}{preload_replace:pre_status="open"}

{exp:channel:entries channel="ch_static"  limit="1" status="{pre_status}" disable="categories|member_data|pagination"}
    {exp:stash:set scope="site"}
        {stash:entry_id}{entry_id}{/stash:entry_id}
        {stash:title}{title}{/stash:title}
        {stash:status}{pre_status}{/stash:status}
        {stash:background_image}{cf_{pre_prefix}_background limit="1"}{url:max_size}{/cf_{pre_prefix}_background}{/stash:background_image}
        {stash:color}{sp_color}{/stash:color}
    {/exp:stash:set}
    {exp:stash:set scope="site" parse_tags='yes' parse_conditionals='yes' save='yes' refresh='60'}
        {stash:main_content}
            {exp:nsm_transplant:body}
                {cf_{pre_prefix}_block_matrix}
                    <article class="content_block{if status == 'Draft'} logged_in{/if}">
                        {if title}<h1>{title}</h1>{/if}
                        {if media AND text}
                            <div class="image">
                                {media}
                            </div>
                            <div class="text">
                                {text}
                            </div>
                        {if:else}
                            {text}{media}
                        {/if}
                    </article><!-- end content_block -->
                {/cf_{pre_prefix}_block_matrix}
                {!--

                    images, video and file replacement with {pre_prefix}

                --}
                {sp_static_img_replacement}
                {sp_video_replacement}
                {sp_file_replacement}
            {/exp:nsm_transplant:body}
            {sp_edit}
        {/stash:main_content}
    {/exp:stash:set}
{/exp:channel:entries}

```

now I love this new approach, but I really don't want to compromise the speed of the site!

any help appreciated! cheers stefan

# Answer
After fiddling around with various options my templates look like this:

**the wrapper template**:

```
<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="utf-8" />
    {exp:seo_lite entry_id="{exp:stash:get name='entry_id'}" parse="inward"}
    <meta property="og:site_name" content="Café Kairo Lorraine"/>
    <meta property="og:title" content="{exp:stash:get name='title'}" />
    <meta property="og:image" content="{exp:stash:get name='og_image'}" />
    {sp_global_head}
    {exp:stash:get name='color'}

</head>
<body id="{segment_1}">

{sp_admin}

{gv_start}

    <header id="header">
        <h1 id="logo"><a href="{path='/'}" class="hide-text">...</a></h1>
    </header>

    <section id="content_container">
        <!-- main navigation -->
        <nav id="main_nav">
            {exp:structure:nav start_from="/" max_depth="1" status="{exp:stash:get name='status'}" css_id="none" parse="inward"}
        </nav><!-- end main_nav -->
        {!-- getting the main content and replacing the needles --}
        {exp:stash:parse process="end"}{exp:stash:get name='main_content'}{/exp:stash:parse}

        {!-- edit links --}
        {exp:stash:get name='edit_main_content' scope="user"}
    </section><!-- end #content_container -->

    <footer id="footer">
        <p>...</p>
    </footer><!-- end #footer -->

{gv_before_end}

{sp_end}

<script type="text/javascript">
    jQuery(function($){
        $.supersized({
            //Background image
            slides  :  [ { image : '{exp:stash:get name='background_image'}' } ]
        });
    });
</script>
{gv_end}

```

**the standard template:**

```
{embed="_wrapper/_standard"}

{preload_replace:pre_prefix="static"}
{if in_group(1)}{preload_replace:pre_status="open|Draft"}{/if}{preload_replace:pre_status="open"}

{exp:channel:entries channel="ch_static" limit="1" status="{pre_status}" disable="categories|member_data|pagination"}

    {!-- misc stuff --}
    {exp:stash:set scope="site"}
        {stash:entry_id}{entry_id}{/stash:entry_id}
        {stash:title}{title}{/stash:title}
        {stash:og_image}{cf_{pre_prefix}_images_matrix limit="1"}{exp:ce_img:pair src="{image_url:url:max_size}" width="250"}{made}{/exp:ce_img:pair}{/cf_{pre_prefix}_images_matrix}{/stash:og_image}
        {stash:status}{pre_status}{/stash:status}
        {stash:background_image}{cf_{pre_prefix}_background limit="1"}{url:max_size}{/cf_{pre_prefix}_background}{/stash:background_image}
        {stash:color}{sp_color}{/stash:color}
    {/exp:stash:set}

    {!-- preparing the content, but not outputting it yet --}
    {exp:stash:set scope="site" name="main_content" parse_tags="yes" parse_conditionals="yes" output="no"}
        {cf_{pre_prefix}_block_matrix}
            <article class="content_block{if status == 'Draft'} logged_in{/if}">
                {if title}<h1>{title}</h1>{/if}
                {if media AND text}
                    <div class="image">
                        {media}
                    </div>
                    <div class="text">
                        {text}
                    </div>
                {if:else}
                    {text}{media}
                {/if}
            </article><!-- end content_block -->
        {/cf_{pre_prefix}_block_matrix}
        <p class="last_edited hidden"><time datetime="{entry_date format="{sp_datetime_format}"}">Letzte Änderung am {edit_date format="%Y-%m-%d"}</time></p>
    {/exp:stash:set}

    {!-- setting the inline edit links --}
    {exp:stash:set scope="user" name="edit_main_content" parse_tags="yes" parse_conditionals="yes"}
        {if member_group == "1"}<p  class="hide_on_demand"><a class="modalbox_edit" href="/backend/index.php?D=cp&C=content_publish&M=entry_form&channel_id={channel_id}&entry_id={entry_id}" title="Zuerst «Senden» drücken, dann «Schliessen und Neuladen»! Esc um abzubrechen">{title} bearbeiten ↑</a></p>{/if}
    {/exp:stash:set}

    {!-- setting the needles --}
    {cf_{pre_prefix}_images_matrix}
        {exp:stash:set name="bild_{row_count}" type="snippet"}
            {if image_zoom == "y"}
                <a class="modalbox_zoom img_link" title="{image_url:title}" href="{exp:ce_img:pair src='{image_url:url:max_size}' width='1200' height='800'}{made}{/exp:ce_img:pair}">
            {/if}
            {exp:switchee variable="{image_size}" parse="inward"}
                {case value="left"}
                    {exp:ce_img:pair src="{image_url:url:max_size}" width="255" allow_scale_larger="yes"}<img src="{made}" class="{image_alignement}" width="{width}" height="{height}" alt="{title} {image_url:title} {image_url:desc} {gv_alt}" />{/exp:ce_img:pair}
                {/case}
                {case value="right"}
                    {exp:ce_img:pair src="{image_url:url:max_size}" width="311" allow_scale_larger="yes"}<img src="{made}" class="{image_alignement}" width="{width}" height="{height}" alt="{title} {image_url:title} {image_url:desc} {gv_alt}" />{/exp:ce_img:pair}
                {/case}
                {case value="full"}
                    {exp:ce_img:pair src="{image_url:url:max_size}" width="600" allow_scale_larger="yes"}<img src="{made}" class="{image_alignement}" width="{width}" height="{height}" alt="{title} {image_url:title} {image_url:desc} {gv_alt}" />{/exp:ce_img:pair}
                {/case}
                {case value="untouched"}
                    <img src="{image_url:url}" width="{image_url:width}" height="{image_url:height}" alt="{title} {image_url:title} {image_url:desc}" class="small_image img_link" />
                {/case}
            {/exp:switchee}
            {if image_zoom == "y"}</a>{/if}
        {/exp:stash:set}
    {/cf_{pre_prefix}_images_matrix}
{/exp:channel:entries}

```

**and here's the log file:**

```
TEMPLATE DEBUGGING
(0.000057 / 13.35MB) - Begin Template Processing -
(0.000177 / 13.35MB) URI: bar
(0.000190 / 13.35MB) Path.php Template: templates/static
(0.000202 / 13.35MB) Retrieving Template
(0.000215 / 13.35MB) Retrieving Template from Database: templates/static
(0.001079 / 13.35MB) Template Found
(0.001152 / 13.36MB) Retrieving Template from File
(0.005293 / 13.80MB) Calling Extension Class/Method: Mo_variables_ext/run
(0.007817 / 14.01MB) Calling Extension Class/Method: Stash_ext/template_fetch_template
(0.007953 / 14.00MB) Template Type: webpage
(0.007973 / 14.00MB) Parsing Site Variables
(0.008046 / 14.00MB) Snippets (Keys): (stripped out)
(0.008134 / 14.02MB) Snippets (Values): (stripped out)
(0.009657 / 14.03MB) Parse Date Format String Constants
(0.009719 / 14.03MB) Parse Current Time Variables
(0.009902 / 14.03MB) Parsing Segment, Embed, and Global Vars Conditionals
(0.011465 / 14.05MB) Processing Preload Text Replacements: pre_prefix|pre_status|pre_status
(0.015727 / 14.13MB) - Beginning Tag Processing -
(0.015758 / 14.12MB) Parsing Tags in Template
(0.015790 / 14.12MB) Tag: {exp:channel:entries channel="ch_static" limit="1" status="open|Draft" disable="categories|member_data|pagination"}
(0.015889 / 14.13MB) Closing Tag Found
(0.015994 / 14.13MB) Processing Tags
(0.016022 / 14.13MB) Module Tag: Channel/entries
(0.016034 / 14.13MB) Including Files for Plugins and Modules
(0.016047 / 14.13MB) Files for Plugins and Modules All Included
(0.016597 / 14.15MB) Beginning Final Tag Data Processing
(0.016614 / 14.15MB) Calling Class/Method: Channel/entries
(0.019813 / 14.17MB) -> Class Called: Channel
(0.021909 / 14.44MB) -> Method Called: entries
(0.063275 / 19.03MB) Calling Extension Class/Method: Assets_ext/channel_entries_query_result
(0.078885 / 20.40MB) Calling Extension Class/Method: Playa_ext/channel_entries_tagdata
(0.080226 / 20.45MB) Calling Extension Class/Method: Matrix_ext/channel_entries_tagdata
(0.252167 / 22.02MB) Calling Extension Class/Method: Pt_field_pack_ext/channel_entries_tagdata
(0.260558 / 22.02MB) -> Data Returned
(0.260695 / 21.97MB) Parsing Tags in Template
(0.260724 / 21.98MB) Tag: {exp:stash:set scope="site"}
(0.260787 / 21.98MB) Closing Tag Found
(0.260863 / 21.98MB) Tag: {exp:stash:set scope="site" name="main_content" parse_tags="yes" parse_conditionals="yes" output="no"}
(0.260930 / 21.98MB) Closing Tag Found
(0.261004 / 21.99MB) Tag: {exp:stash:set scope="user" name="edit_main_content" parse_tags="yes" parse_conditionals="yes"}
(0.261067 / 21.99MB) Closing Tag Found
(0.261121 / 21.99MB) Tag: {exp:ifelse parse="inward"}
(0.261172 / 21.99MB) Closing Tag Found
(0.261242 / 21.99MB) Tag: {exp:ifelse parse="inward"}
(0.261287 / 21.99MB) Closing Tag Found
(0.261331 / 22.00MB) Tag: {exp:ifelse parse="inward"}
(0.261375 / 22.00MB) Closing Tag Found
(0.261409 / 22.00MB) Processing Tags
(0.261455 / 22.00MB) Module Tag: Stash/set
(0.261477 / 22.00MB) Module Tag: Stash/set
(0.261497 / 22.00MB) Module Tag: Stash/set
(0.261525 / 22.00MB) Plugin Tag: Ifelse/
(0.261547 / 22.00MB) Plugin Tag: Ifelse/
(0.261569 / 22.00MB) Plugin Tag: Ifelse/
(0.261584 / 22.00MB) Including Files for Plugins and Modules
(0.267416 / 22.80MB) Files for Plugins and Modules All Included
(0.267441 / 22.80MB) Beginning Final Tag Data Processing
(0.267458 / 22.80MB) Calling Class/Method: Stash/set
(0.267821 / 22.79MB) -> Class Called: Stash
(0.269202 / 22.91MB) -> Method Called: set
(0.269375 / 22.91MB) Stash: SET entry_id to value 1130
(0.269477 / 22.91MB) Stash: SET title to value Bar
(0.269579 / 22.91MB) Stash: SET og_image to value {exp:ce_img:pair src="http://www.mydomain.ch/media/bilder/_max_size/bar.jpg" width="250"}{made}{/exp:ce_img:pair}
(0.269679 / 22.91MB) Stash: SET status to value open|Draft
(0.269782 / 22.92MB) Stash: SET background_image to value http://www.mydomain.ch/media/hintergrund/_max_size/Lueftungstapete.jpg
(0.269902 / 22.92MB) Stash: SET color to value <style> a:hover, .link:hover, #main_nav li a:hover, #main_nav li.here a, #main_nav li.parent-here a { color: #837b3d; } #main_nav { position: relative; float: left; border-bottom-color: #837b3d; } .content_block.line { border-bottom-color: #837b3d; } .time_divider h1 { color: #837b3d; } </style>
(0.269988 / 22.91MB) -> Data Returned
(0.270014 / 22.91MB) Calling Class/Method: Stash/set
(0.270148 / 22.91MB) -> Class Called: Stash
(0.270337 / 22.91MB) -> Method Called: set
(0.270385 / 22.91MB) Stash: processing inner tags
(0.270731 / 22.91MB) Calling Extension Class/Method: Stash_ext/template_fetch_template
(0.272446 / 22.91MB) Calling Extension Class/Method: Mo_variables_ext/cleanup
(0.272631 / 22.91MB) Calling Extension Class/Method: Stash_ext/template_post_parse
(0.273548 / 22.92MB) Calling Extension Class/Method: Structure_ext/template_post_parse
(0.273748 / 22.91MB) Stash: SET main_content to value <article class="content_block"> <h1>Trinken im Kairo</h1> <p>{bild_2}</p> <p>...</p>
(0.273818 / 22.90MB) -> Data Returned
(0.273845 / 22.90MB) Calling Class/Method: Stash/set
(0.273945 / 22.90MB) -> Class Called: Stash
(0.274126 / 22.91MB) -> Method Called: set
(0.274171 / 22.91MB) Stash: processing inner tags
(0.274450 / 22.91MB) Calling Extension Class/Method: Stash_ext/template_fetch_template
(0.275500 / 22.91MB) Calling Extension Class/Method: Mo_variables_ext/cleanup
(0.275673 / 22.91MB) Calling Extension Class/Method: Stash_ext/template_post_parse
(0.276391 / 22.92MB) Calling Extension Class/Method: Structure_ext/template_post_parse
(0.276549 / 22.91MB) Stash: SET edit_main_content to value <p class="hide_on_demand"><a class="modalbox_edit" href="/backend/index.php?D=cp&C=content_publish&M=entry_form&channel_id=1&entry_id=1130" title="Zuerst Â«SendenÂ» drÃ¼cken, dann Â«Schliessen und NeuladenÂ»! Esc um abzubrechen">Bar bearbeiten ↑</a></p>
(0.276615 / 22.91MB) -> Data Returned
(0.276641 / 22.90MB) Calling Class/Method: Ifelse/
(0.278100 / 22.92MB) -> Class Called: Ifelse
(0.278576 / 22.93MB) -> Method Called: Ifelse
(0.278648 / 22.93MB) -> Data Returned
(0.278674 / 22.92MB) Calling Class/Method: Ifelse/
(0.278838 / 22.91MB) -> Class Called: Ifelse
(0.279210 / 22.91MB) -> Method Called: Ifelse
(0.279281 / 22.91MB) -> Data Returned
(0.279308 / 22.91MB) Calling Class/Method: Ifelse/
(0.279403 / 22.91MB) -> Class Called: Ifelse
(0.279753 / 22.91MB) -> Method Called: Ifelse
(0.279825 / 22.91MB) -> Data Returned
(0.279877 / 22.87MB) Parsing Tags in Template
(0.279903 / 22.88MB) Tag: {exp:stash:set name="bild_1" type="snippet"}
(0.279965 / 22.88MB) Closing Tag Found
(0.280027 / 22.88MB) Tag: {exp:stash:set name="bild_2" type="snippet"}
(0.280081 / 22.88MB) Closing Tag Found
(0.280137 / 22.88MB) Tag: {exp:stash:set name="datei_1" type="snippet"}
(0.280187 / 22.89MB) Closing Tag Found
(0.280224 / 22.89MB) Processing Tags
(0.280252 / 22.89MB) Module Tag: Stash/set
(0.280273 / 22.89MB) Module Tag: Stash/set
(0.280293 / 22.89MB) Module Tag: Stash/set
(0.280307 / 22.89MB) Including Files for Plugins and Modules
(0.280318 / 22.89MB) Files for Plugins and Modules All Included
(0.280328 / 22.89MB) Beginning Final Tag Data Processing
(0.280340 / 22.89MB) Calling Class/Method: Stash/set
(0.280945 / 22.90MB) -> Class Called: Stash
(0.281131 / 22.90MB) -> Method Called: set
(0.281210 / 22.91MB) Stash: SET bild_1 to value ...
(0.281285 / 22.90MB) -> Data Returned
(0.281308 / 22.90MB) Calling Class/Method: Stash/set
(0.281921 / 22.90MB) -> Class Called: Stash
(0.282105 / 22.91MB) -> Method Called: set
(0.282183 / 22.91MB) Stash: SET bild_2 to value ...
(0.282262 / 22.91MB) -> Data Returned
(0.282286 / 22.90MB) Calling Class/Method: Stash/set
(0.282394 / 22.90MB) -> Class Called: Stash
(0.282590 / 22.90MB) -> Method Called: set
(0.282674 / 22.91MB) Stash: SET datei_1 to value <a href="http://www.mydomain.ch/media/dateien/Kairo_Kellervermietung.pdf" class="download_icon">...</a>
(0.282755 / 22.90MB) -> Data Returned
(0.282781 / 22.90MB) - End Tag Processing -
(0.282827 / 22.90MB) - Processing Sub Templates (Depth: 1) -
(0.282846 / 22.90MB)      List of Embeds: _wrapper/_standard
(0.282896 / 22.90MB)      Processing Sub Template: _wrapper/_standard
(0.282913 / 22.90MB)      Retrieving Template
(0.282927 / 22.90MB)      Retrieving Template from Database: _wrapper/_standard
(0.283956 / 22.91MB)      Template Found
(0.284046 / 22.91MB)      Retrieving Template from File
(0.284630 / 22.93MB)      Calling Extension Class/Method: Stash_ext/template_fetch_template
(0.284762 / 22.91MB)      Template Type: webpage
(0.284792 / 22.91MB)      Parsing Site Variables
(0.284876 / 22.92MB)      Snippets (Keys): (stripped out)|bild_1|bild_2|datei_1
(0.284961 / 22.96MB)      Snippets (Values): (stripped out) ...
(0.286013 / 22.94MB)      Parse Date Format String Constants
(0.286240 / 22.95MB)      Parse Current Time Variables
(0.286317 / 22.95MB)      Parsing Segment, Embed, and Global Vars Conditionals
(0.286679 / 22.95MB)      Processing Preload Text Replacements: var_message
(0.286726 / 22.95MB)       - Beginning Tag Processing -
(0.286749 / 22.93MB)      Parsing Tags in Template
(0.286804 / 22.94MB)      Tag: {exp:seo_lite entry_id="{exp:stash:get name='entry_id'}" parse="inward"}
(0.286868 / 22.94MB)      No Closing Tag
(0.286921 / 22.94MB)      Tag: {exp:stash:get name='title'}
(0.286975 / 22.95MB)      No Closing Tag
(0.287029 / 22.95MB)      Tag: {exp:stash:get name='og_image'}
(0.287082 / 22.95MB)      No Closing Tag
(0.287138 / 22.95MB)      Tag: {exp:stash:get name='color'}
(0.287189 / 22.95MB)      No Closing Tag
(0.287282 / 22.96MB)      Tag: {exp:structure:nav start_from="/" max_depth="1" status="{exp:stash:get name='status'}" css_id="none" parse="inward"}
(0.287353 / 22.95MB)      No Closing Tag
(0.287409 / 22.96MB)      Tag: {exp:stash:parse process="end"}
(0.287461 / 22.96MB)      Closing Tag Found
(0.287519 / 22.96MB)      Tag: {exp:stash:get name='edit_main_content' scope="user"}
(0.287574 / 22.96MB)      No Closing Tag
(0.287635 / 22.97MB)      Tag: {exp:stash:get name='background_image'}
(0.287683 / 22.96MB)      No Closing Tag
(0.287728 / 22.97MB)      Processing Tags
(0.287755 / 22.97MB)      Module Tag: Seo_lite/
(0.287778 / 22.97MB)      Module Tag: Stash/get
(0.287802 / 22.97MB)      Module Tag: Stash/get
(0.287823 / 22.97MB)      Module Tag: Stash/get
(0.287844 / 22.97MB)      Module Tag: Structure/nav
(0.287865 / 22.97MB)      Module Tag: Stash/parse
(0.287885 / 22.97MB)      Module Tag: Stash/get
(0.287906 / 22.97MB)      Module Tag: Stash/get
(0.287923 / 22.97MB)      Including Files for Plugins and Modules
(0.288793 / 23.07MB)      Files for Plugins and Modules All Included
(0.288811 / 23.07MB)      Beginning Final Tag Data Processing
(0.288826 / 23.07MB)      Calling Class/Method: Seo_lite/
(0.288846 / 23.07MB)      Plugin in Parameter, Processing Plugin First
(0.288924 / 23.09MB) Tag: {exp:stash:get name='entry_id'}
(0.288975 / 23.09MB) No Closing Tag
(0.289025 / 23.09MB) Module Tag: Stash/get
(0.289039 / 23.09MB) Including Files for Plugins and Modules
(0.289050 / 23.09MB) Files for Plugins and Modules All Included
(0.289469 / 23.12MB) Beginning Final Tag Data Processing
(0.289487 / 23.12MB) Calling Class/Method: Stash/get
(0.289567 / 23.12MB) -> Class Called: Stash
(0.289761 / 23.13MB) -> Method Called: get
(0.289823 / 23.13MB) Stash: RETRIEVED entry_id with value 1130
(0.289926 / 23.13MB) -> Data Returned
(0.290139 / 23.08MB)       -> Class Called: Seo_lite
(0.291888 / 23.07MB)       -> Method Called: Seo_lite
(0.291966 / 23.07MB)       -> Data Returned
(0.292002 / 23.07MB)      Calling Class/Method: Stash/get
(0.292075 / 23.07MB)       -> Class Called: Stash
(0.292256 / 23.08MB)       -> Method Called: get
(0.292309 / 23.08MB)      Stash: RETRIEVED title with value Bar
(0.292407 / 23.08MB)       -> Data Returned
(0.292452 / 23.08MB)      Calling Class/Method: Stash/get
(0.292526 / 23.08MB)       -> Class Called: Stash
(0.292705 / 23.08MB)       -> Method Called: get
(0.292760 / 23.08MB)      Stash: RETRIEVED og_image with value {exp:ce_img:pair src="http://www.mydomain.ch/media/bilder/_max_size/bar.jpg" width="250"}{made}{/exp:ce_img:pair}
(0.292861 / 23.08MB)       -> Data Returned
(0.292897 / 23.08MB)      Calling Class/Method: Stash/get
(0.292969 / 23.08MB)       -> Class Called: Stash
(0.293146 / 23.08MB)       -> Method Called: get
(0.293202 / 23.08MB)      Stash: RETRIEVED color with value ...
(0.293301 / 23.08MB)       -> Data Returned
(0.293338 / 23.08MB)      Calling Class/Method: Structure/nav
(0.293358 / 23.08MB)      Plugin in Parameter, Processing Plugin First
(0.293420 / 23.09MB) Tag: {exp:stash:get name='status'}
(0.293476 / 23.10MB) No Closing Tag
(0.293525 / 23.10MB) Module Tag: Stash/get
(0.293539 / 23.10MB) Including Files for Plugins and Modules
(0.293549 / 23.10MB) Files for Plugins and Modules All Included
(0.293933 / 23.12MB) Beginning Final Tag Data Processing
(0.293950 / 23.12MB) Calling Class/Method: Stash/get
(0.294022 / 23.13MB) -> Class Called: Stash
(0.294203 / 23.13MB) -> Method Called: get
(0.294257 / 23.13MB) Stash: RETRIEVED status with value open|Draft
(0.294355 / 23.13MB) -> Data Returned
(0.294572 / 23.08MB)       -> Class Called: Structure
(0.294905 / 23.10MB)       -> Method Called: nav
(0.300818 / 23.22MB)       -> Data Returned
(0.300870 / 23.20MB)      Calling Class/Method: Stash/parse
(0.300980 / 23.20MB)       -> Class Called: Stash
(0.301178 / 23.21MB)       -> Method Called: parse
(0.301216 / 23.21MB)      Stash: this tag will be post-processed on end: {exp:stash:parse process="end"}
(0.301300 / 23.21MB)       -> Data Returned
(0.301337 / 23.21MB)      Calling Class/Method: Stash/get
(0.301410 / 23.21MB)       -> Class Called: Stash
(0.301598 / 23.21MB)       -> Method Called: get
(0.301655 / 23.21MB)      Stash: RETRIEVED edit_main_content with value ...
(0.301753 / 23.21MB)       -> Data Returned
(0.301790 / 23.21MB)      Calling Class/Method: Stash/get
(0.301865 / 23.21MB)       -> Class Called: Stash
(0.302051 / 23.21MB)       -> Method Called: get
(0.302104 / 23.21MB)      Stash: RETRIEVED background_image with value http://www.mydomain.ch/media/hintergrund/_max_size/Lueftungstapete.jpg
(0.302202 / 23.21MB)       -> Data Returned
(0.302270 / 23.18MB)      Parsing Tags in Template
(0.302299 / 23.18MB)      Tag: {exp:ce_img:pair src="http://www.mydomain.ch/media/bilder/_max_size/bar.jpg" width="250"}
(0.302364 / 23.18MB)      Closing Tag Found
(0.302420 / 23.19MB)      Processing Tags
(0.302454 / 23.19MB)      Plugin Tag: Ce_img/pair
(0.302468 / 23.19MB)      Including Files for Plugins and Modules
(0.305107 / 23.56MB)      Files for Plugins and Modules All Included
(0.305124 / 23.56MB)      Beginning Final Tag Data Processing
(0.305139 / 23.56MB)      Calling Class/Method: Ce_img/pair
(0.305243 / 23.56MB)       -> Class Called: Ce_img
(0.305277 / 23.56MB)       -> Method Called: pair
(0.317498 / 25.02MB)        ***  CE Image debug: Base path: '/my_server_path/'
(0.317519 / 25.02MB)        ***  CE Image debug: Source image: 'http://www.mydomain.ch/media/bilder/_max_size/bar.jpg', Fallback image: ''
(0.317531 / 25.02MB)        ***  CE Image debug: The image '/my_server_path/media/bilder/_max_size/bar.jpg' is cached.
(0.317975 / 25.00MB)       -> Data Returned
(0.318039 / 24.99MB)       - End Tag Processing -
(0.318073 / 24.99MB)      Processing Advanced Conditionals
(0.319817 / 24.99MB)      Calling Extension Class/Method: Mo_variables_ext/cleanup
(0.319997 / 24.99MB)      Calling Extension Class/Method: Stash_ext/template_post_parse
(0.320839 / 24.99MB)      Calling Extension Class/Method: Structure_ext/template_post_parse
(0.321312 / 25.00MB) Calling Extension Class/Method: Mo_variables_ext/cleanup
(0.321507 / 25.01MB) Calling Extension Class/Method: Stash_ext/template_post_parse
(0.321763 / 25.02MB) Stash: post-processing tag: {exp:stash:parse process="end"} will be replaced into {6ee64145dfa4ae5926a9c326266d59541297750798}
(0.321843 / 25.02MB) Stash: processing inner tags
(0.322131 / 25.02MB) Calling Extension Class/Method: Stash_ext/template_fetch_template
(0.322576 / 25.02MB) Tag: {exp:stash:get name='main_content'}
(0.322635 / 25.02MB) No Closing Tag
(0.322699 / 25.02MB) Module Tag: Stash/get
(0.322713 / 25.02MB) Including Files for Plugins and Modules
(0.322725 / 25.02MB) Files for Plugins and Modules All Included
(0.323373 / 25.05MB) Beginning Final Tag Data Processing
(0.323391 / 25.05MB) Calling Class/Method: Stash/get
(0.323486 / 25.05MB) -> Class Called: Stash
(0.323684 / 25.06MB) -> Method Called: get
(0.323752 / 25.06MB) Stash: RETRIEVED main_content with value <article class="content_block"> <h1>Trinken im Kairo</h1> <p>{bild_2}</p> <p>...</p>
(0.323861 / 25.06MB) -> Data Returned
(0.323967 / 25.02MB) Stash: processing inner tags
(0.324455 / 25.03MB) Tag: {exp:ce_img:pair src='http://www.mydomain.ch/media/bilder/_max_size/_ULI_Kairo_02.JPG' width='1200' height='800'}
(0.324522 / 25.03MB) Closing Tag Found
(0.324570 / 25.03MB) Tag: {exp:switchee variable="full" parse="inward"}
(0.324624 / 25.04MB) Closing Tag Found
(0.324690 / 25.04MB) Plugin Tag: Ce_img/pair
(0.324716 / 25.04MB) Plugin Tag: Switchee/
(0.324730 / 25.04MB) Including Files for Plugins and Modules
(0.325425 / 25.11MB) Files for Plugins and Modules All Included
(0.325466 / 25.11MB) Beginning Final Tag Data Processing
(0.325481 / 25.11MB) Calling Class/Method: Ce_img/pair
(0.325583 / 25.11MB) -> Class Called: Ce_img
(0.325610 / 25.11MB) -> Method Called: pair
(0.327154 / 25.14MB)   ***  CE Image debug: Base path: '/my_server_path/'
(0.327168 / 25.14MB)   ***  CE Image debug: Source image: 'http://www.mydomain.ch/media/bilder/_max_size/_ULI_Kairo_02.JPG', Fallback image: ''
(0.327178 / 25.14MB)   ***  CE Image debug: The image '/my_server_path/images/made/media/bilder/_max_size/_ULI_Kairo_02_1200_800.JPG' is cached.
(0.327765 / 25.13MB) -> Data Returned
(0.327791 / 25.13MB) Calling Class/Method: Switchee/
(0.328271 / 25.13MB) -> Class Called: Switchee
(0.328831 / 25.13MB) -> Method Called: Switchee
(0.328908 / 25.13MB) -> Data Returned
(0.329007 / 25.09MB) Stash: processing inner tags
(0.329551 / 25.10MB) Tag: {exp:ce_img:pair src="http://www.mydomain.ch/media/bilder/_max_size/_ULI_Kairo_02.JPG" width="600" allow_scale_larger="yes"}
(0.329617 / 25.10MB) Closing Tag Found
(0.329677 / 25.11MB) Plugin Tag: Ce_img/pair
(0.329691 / 25.11MB) Including Files for Plugins and Modules
(0.329702 / 25.11MB) Files for Plugins and Modules All Included
(0.329733 / 25.11MB) Beginning Final Tag Data Processing
(0.329746 / 25.11MB) Calling Class/Method: Ce_img/pair
(0.329863 / 25.11MB) -> Class Called: Ce_img
(0.329888 / 25.11MB) -> Method Called: pair
(0.331330 / 25.14MB)   ***  CE Image debug: Base path: '/my_server_path/'
(0.331343 / 25.14MB)   ***  CE Image debug: Source image: 'http://www.mydomain.ch/media/bilder/_max_size/_ULI_Kairo_02.JPG', Fallback image: ''
(0.331352 / 25.14MB)   ***  CE Image debug: The image '/my_server_path/images/made/media/bilder/_max_size/_ULI_Kairo_02_600_400_s.JPG' is cached.
(0.331856 / 25.12MB) -> Data Returned
(0.332686 / 25.10MB) Calling Extension Class/Method: Mo_variables_ext/cleanup
(0.332865 / 25.10MB) Calling Extension Class/Method: Stash_ext/template_post_parse
(0.333805 / 25.11MB) Calling Extension Class/Method: Structure_ext/template_post_parse
(0.334644 / 25.09MB) Calling Extension Class/Method: Structure_ext/template_post_parse
(0.334842 / 25.07MB) - End Template Processing -
(0.334855 / 25.07MB) Parse Global Variables
(0.338096 / 25.08MB) Template Parsing Finished
Memory Usage: 27,221,456 bytes

```

one thing I've learned here is that the wrapper template should absolutely contain NO EMBEDS!

Initially I had 2 embeds within the wrapper template and this was slowing down performance!

still: if anybody knows anything on how to even speed up things, you're very much welcome with your suggestions!

mark: thanks for being so helpful already!
> 1 votes

# Answer
I'm not sure it explains the .5 second load time difference, but while you are trying to save the main content variable you are actually replacing the variable on every page view:

```
{exp:stash:set scope="site" parse_tags='yes' parse_conditionals='yes' save='yes' refresh='60'}

```

If you add the `replace="no"` parameter then the cache won't be rebuilt with every page view. Instead, it will only be rebuilt after the `refresh="x"` period specified.

```
{exp:stash:set scope="site" parse_tags="yes" parse_conditionals="yes" save="yes" refresh='60' replace="no"}

```

That will help get the queries down, however the longer processing time is most likely some kind of recursion. My *guess* is nsm\_transplant might be in conflict with Stash in some way.
> 0 votes

---
Tags: stash, performance
---


# Question
Title: Stash only outputting 1 of each item rather than 15 as set by channel entries limit - help
EE 2.5.5 Stash 2.1.0

I'm new to stash and am in the middle of integrating EE into existing html code.

The code I currently have is as follows:

```
{exp:stash:set parse_tags="yes"}
    {stash:content}
      {exp:channel:entries channel="photoblog" limit="15" orderby="" disable="member_data|pagination|categories"}

          {stash:title}
            <div {if count=="1"}style="display:block;"{/if}>
              <h2>{title}</h2>
            </div>
          {/stash:title}

          {stash:photos}
            {photos}
            <img class="pg_thumb" {if count=="1"}style="display:block;"{/if} src="{image}" width="1000" height="714" alt="" />
            {/photos}
          {/stash:photos}

          {stash:description}
            <div {if count=="1"}style="display:block;"{/if}>
              {description}
              <a href="#" class="more">Details</a>
            </div>
          {/stash:description}

      {/exp:channel:entries}
    {/stash:content}
{/exp:stash:set}

    <div id="pg_preview">
      {exp:stash:get name="photos"}
    </div>

    <div id="pg_desc1" class="pg_description">
        {exp:stash:get name="title"}
    </div><!--pg_desc1-->

    <div id="pg_desc2" class="pg_description">
        {exp:stash:get name="description"}
    </div><!--pg_desc2-->

```

This is sort of working. When I check the front end code I see only one result for each of the get tags when I'm actually expecting to see 15 as per the limit parameter of the channel entries tag.

### UPDATE

I just tried the following, but all it does is output about 30 blank lines

```
{exp:channel:entries channel="photoblog" limit="15" orderby="" disable="member_data|pagination|categories"}
    {exp:stash:set_list name="photos-list" parse_tags="yes"}
          {stash:entry_id}{entry_id}{/stash:entry_id}
          {stash:title}
            {title}
          {/stash:title}

          {stash:photos}
            {photos}
            <img class="pg_thumb" {if count=="1"}style="display:block;"{/if} src="{image}" width="1000" height="714" alt="" />
            {/photos}
          {/stash:photos}

          {stash:description}
            {description}
          {/stash:description}
    {/exp:stash:set_list}
{/exp:channel:entries}

{exp:stash:get_list name="photos-list" orderby="entry_id" sort="asc" limit="15"}
    <div id="pg_preview">
      {photos}
    </div>

    <div id="pg_desc1" class="pg_description">
      <div {if count=="1"}style="display:block;"{/if}>
        <h2>{title}</h2>
      </div>
    </div><!--pg_desc1-->

    <div id="pg_desc2" class="pg_description">
        <div {if count=="1"}style="display:block;"{/if}>
          {description}
          <a href="#" class="more">Details</a>
        </div>
    </div><!--pg_desc2-->
{/exp:stash:get_list}

```

### UPDATE 2

I changed the code that was here just before reading dylans comment, which looks the same to me, but it isn't working.

```
{exp:stash:set_list name="photos-list" parse_tags="yes" output="no"}
  {exp:channel:entries channel="photoblog" limit="5" orderby="" disable="member_data|pagination|categories"}

      {stash:entry_id}{entry_id}{/stash:entry_id}
      {stash:title}
        {title}
      {/stash:title}

      {stash:photos}
        {photos}
        <img class="pg_thumb" {if count=="1"}style="display:block;"{/if} src="{image}" width="1000" height="714" alt="{title}" />
        {/photos}
      {/stash:photos}

      {stash:description}
        {description}
      {/stash:description}

  {/exp:channel:entries}
{/exp:stash:set_list}

{exp:stash:get_list name="photos-list" orderby="entry_id" sort="asc" limit="5" output="yes"}
    <div id="pg_preview">
      {photos}
    </div>

    <div id="pg_desc1" class="pg_description">
      <div {if count=="1"}style="display:block;"{/if}>
        <h2>{title}</h2>
      </div>
    </div><!--pg_desc1-->

    <div id="pg_desc2" class="pg_description">
        <div {if count=="1"}style="display:block;"{/if}>
          {description}
          <a href="#" class="more">Details</a>
        </div>
    </div><!--pg_desc2-->
{/exp:stash:get_list}

```

### UPDATE 3

Newly revised code below based on Nate's comment to his own answer. Not working as expected. I still only see one entry worth of data, but the image is now not the correct one. Have created a stripped down template with only the following code for testing purposes which can be viewed here. That picture is from December but the copy is from Feb 8. Not sure why the photo is not pulling from the same entry as the copy.

--updated to stash 2.3.6 and multiple entries now working, but the same image is displaying for all of them.

```
{exp:stash:set_list name="photos-list" parse_tags="yes" output="no" parse_depth="2" parse_conditionals="yes" prefix="prefix"}
  {exp:channel:entries channel="photoblog" limit="5" orderby="" disable="member_data|pagination|categories" dynamic="no"}

      {stash:entry_id}{entry_id}{/stash:entry_id}
      {stash:title}
        {title}
      {/stash:title}

      {exp:stash:set_list:nested name="photos-image" parse_tags="yes" output="yes" parse_conditionals="yes" prefix="prefix"}
        {stash:picture}
          {photos}
          <img class="pg_thumb" {if prefix:count=="1"}style="display:block;"{/if} src="{image}" width="1000" height="714" alt="{title}" />
          {/photos}
        {/stash:picture}
      {/exp:stash:set_list:nested}

      {stash:description}
        {description}
      {/stash:description}

  {/exp:channel:entries}
{/exp:stash:set_list}

{exp:stash:get_list name="photos-list" orderby="entry_id" sort="asc" limit="5" output="yes" parse_conditionals="yes" prefix="prefix"}

    <div id="pg_preview">
      {exp:stash:get_list:nested name="photos-image"}
        {picture}
      {/exp:stash:get_list:nested}
    </div>

    <div id="pg_desc1" class="pg_description">
      <div {if prefix:count=="1"}style="display:block;"{/if}>
        <h2>{title}</h2>
      </div>
    </div><!--pg_desc1-->

    <div id="pg_desc2" class="pg_description">
        <div {if prefix:count=="1"}style="display:block;"{/if}>
          {description}
          <a href="#" class="more">Details</a>
        </div>
    </div><!--pg_desc2-->

{/exp:stash:get_list}

```

Please advise.

### UPDATE AGAIN

Am very flummoxed with this. I have pasted template code here that works perfectly, but is using 4 duplicate channel entries tags. If someone could help me get this working with stash I would be very grateful. It would also help if I can not just copy and paste, but fully understand what is happening.

# Answer
> 2 votes
There's two problems with your second example that I can see. The first is the EE parse order. To quote Mark Croxton:

> Like the layers of an onion, EE parses module tags from the outwards \> inwards - ‘peeling off’ the outer tags in a template to expose the ones nested inside.

So basically you're trying to display the stash variable before it's actually been set.

The second is that your stash list is being overwritten with every loop of the channel entries tag.

The easiest way to solve this would be to swap the order of your channel:entries and stash tags. Stash is smart enough to see that it's dealing with multiple entries and will add a new row for each one. The parse order issue is solved as you've included the `parse_tags="yes"` parameter, but now it's actually parsing the channel:entries tag because it's on the outside. Here's a simple example:

```
{exp:stash:set_list name="photos-list" parse_tags="yes"}
    {exp:channel:entries channel="photoblog" limit="15" orderby="" disable="member_data|pagination|categories"}
        {stash:entry_id}{entry_id}{/stash:entry_id}
        {stash:title}{title}{/stash:title}
        {stash:description}{description}{/stash:description}
    {/exp:channel:entries}
{/exp:stash:set_list}

{exp:stash:get_list name="photos-list" orderby="entry_id" sort="asc" limit="15"}
   <h2>{title}</h2>
   {description}
{/exp:stash:get_list}

```

I'd highly recommend reading the following EE Insider article that describes the template partial approach using stash. Stash and the EE parse order can be a bit hard to get your head around at first but open up enormous possibilities once you get the hang of it.

### Update 3 response

Okay in regard to your third update with only one image showing. It sounds like it's just showing the first image that's been stashed in the nested list. You should be able to use the match parameter to sort this out. Stash the current entry\_id in your nested list:

```
{stash:entry_id}{entry_id}{/stash:entry_id}

```

and then match against it when you get the list:

```
{exp:stash:get_list:nested name="photos-image" match="#^{entry_id}$#" against="entry_id"}

```

# Answer
> 1 votes
Give this a try (see EE comments in the code itself)

**Note: this is based on Stash 2.3.6**

```
{exp:channel:entries channel="photoblog" limit="15" disable="member_data|pagination|categories"}

    {exp:stash:set_list name="photos-list" parse_tags="yes"}

        {!-- I set up my variables with this_ or stash_ so when people look at {title} var they know it's a stash variable
            vs not a normal title var like you had.
        --}

        {stash:this_entry_id}{entry_id}{/stash:this_entry_id}

        {stash:this_title}{title}{/stash:this_title}

        {stash:this_description}{description}{/stash:this_description}

        {!-- What is photos here? If matrix you MAY need to put photos on the outside of stash:this_photos
        I try and name space like so: channel_fieldtype_name so this might be photoblog_matrix_photos (if it fits.)
        This syntax makes it nice for the next dev for what ever it's worth. Also if you can help it try and keep your viewModel html free and put that in the view itself (this get_list in this case.)
        --}
        {photos}
        {stash:this_photos}{image}{/stash:this_photos}
        {/photos}

    {/exp:stash:set_list}

{/exp:channel:entries}

{!-- You need to use parse_conditionals for your IFs and it's a good idea to prefix your count vars --}
{exp:stash:get_list name="photos-list" orderby="this_entry_id" sort="asc" prefix="prefix" parse_conditionals="yes"}
    <div id="pg_preview">
        <img class="pg_thumb" {if prefix:count=="1"}style="display:block;"{/if} src="{this_photo}" width="1000" height="714" alt="" />
    </div>

    <div id="pg_desc1" class="pg_description">
        <div {if prefix:count=="1"}style="display:block;"{/if}>
            <h2>{this_title}</h2>
        </div>
    </div><!--pg_desc1-->

    <div id="pg_desc2" class="pg_description">
        <div {if prefix:count=="1"}style="display:block;"{/if}>
            {this_description}
            <a href="#" class="more">Details</a>
        </div>
    </div><!--pg_desc2-->
{/exp:stash:get_list}

```

**Update**

```
{exp:stash:set_list name="photos-list" parse_tags="yes" parse_depth="2"}

    {exp:channel:entries channel="photoblog" limit="15" disable="member_data|pagination|categories"}

        {stash:entry_id}{entry_id}{/stash:entry_id}

        {stash:title}{title}{/stash:title}

        {stash:description}{description}{/stash:description}

        {!-- try append list here instead if set list doesn't work --}
        {stash:append_list:nested name="photos-matrix" parse_tags="yes"}
            {photos}
                {stash:photos}{image}{/stash:photos}
            {/photos}
        {/stash:append_list:nested}

    {/exp:channel:entries}

{/exp:stash:set_list}

{!-- You need to use parse_conditionals for your IFs and it's a good idea to prefix your count vars - note that you might get away with leaving off :nested on the end of the get list here because, well, it's not nested. --}
<div id="pg_preview">
    {exp:stash:get_list:nested name="photos-matrix" orderby="entry_id" sort="asc" prefix="prefix" parse_conditionals="yes"}
        <img class="pg_thumb" {if prefix:count=="1"}style="display:block;"{/if} src="{photo}" width="1000" height="714" alt="" />
    {/exp:stash:get_list:nested}
</div>

{exp:stash:get_list name="photos-list" orderby="entry_id" sort="asc" prefix="prefix" parse_conditionals="yes"}
    <div id="pg_desc1" class="pg_description">
        <div {if prefix:count=="1"}style="display:block;"{/if}>
            <h2>{title}</h2>
        </div>
    </div><!--pg_desc1-->

    <div id="pg_desc2" class="pg_description">
        <div {if prefix:count=="1"}style="display:block;"{/if}>
            {description}
            <a href="#" class="more">Details</a>
        </div>
    </div><!--pg_desc2-->
{/exp:stash:get_list}

```

# Answer
> 1 votes
Try this, if it works I'll attempt to explain it!!

Main template (the template that's called by the URL)

```
{!-- ====================================
FETCH AND CACHE THE RAW DATASET
========================================= --}

{exp:stash:set_list name="data" parse_tags="yes" parse_conditionals="yes" parse_depth="2"}
    {exp:channel:entries channel="photoblog" limit="14" dynamic="no"}
        {stash:titles}{title}{/stash:titles}
        {stash:descriptions}{description}{/stash:descriptions}
        {exp:stash:set_list:2 name="photo_urls" parse_tags="yes" context="cx{count}"}{photos}{stash:url}{image}{/stash:url}{/photos}{/exp:stash:set_list:2}
    {/exp:channel:entries}
{/exp:stash:set_list}

{!-- ====================================
ASSEMBLE MARKUP AROUND THE DATA, ready for
use in the View.
========================================= --}

{exp:stash:get_list name="data"}

    {exp:stash:append name="desc1"}
        <div {if count=='1'}style="display:block;"{/if}>
            <h2>{titles}</h2>
        </div>
    {/exp:stash:append}

    {exp:stash:append name="desc2"}
    <div {if count=='1'}style="display:block;"{/if}>
        {descriptions}
        <a href="#" class="more">Details</a>
    </div>
    {/exp:stash:append}

    {exp:stash:get_list:2 name="photo_urls" context="cx{count}"}

        {exp:stash:append name="preview_photos"}
            <img class="pg_thumb" {if count=='1'}style="display:block;"{/if} src="{url}" width="900" height="550" alt="" />
        {/exp:stash:append}

        {exp:stash:append name="slider"}
            <div class="content {if count=='1'}first{/if}{if count=='14'}last{/if}">
                <div><a class="slide-h act" href="#">{exp:ce_img:pair src="{url}" width="120" height="90" crop="yes"}<img src="{made}" alt="" width="{width}" height="{height}" class="thumb" />{/exp:ce_img:pair}<i></i></a></div>
            </div>
        {/exp:stash:append}

    {/exp:stash:get_list:2}

{/exp:stash:get_list}

{!-- ====================================
EMBED the VIEW
========================================= --}

{embed=site/view}

```

Embedded View template:

```
<div id="holder" class="h">
  <div class="pg_content">

    <div id="pg_preview">
      {exp:stash:preview_photos}
    </div>

    <div id="pg_desc1" class="pg_description">
      {exp:stash:desc1}
    </div><!--pg_desc1-->

    <div id="pg_desc2" class="pg_description">
      {exp:stash:desc2}
    </div><!--pg_desc2-->

  </div>

  <div id="big-mask"></div>

  <div id="thumbContainter">
    <div id="thumbScroller">
      <div class="container">
        {exp:stash:slider}
        <div class="marker"></div>
      </div>

    </div>
  </div><!--thumbContainter-->

</div> <!--holder-->

```

# Answer
> 1 votes
Well I think you're nearly there; first you need the name given to the inner list to be linked to the outer list row item - at the moment you are overwriting it with each iteration of the outer list when you set the lists. You can use `{entry_id}` as the namespace for that, either as a suffix appended to the inner list name or as the specified context for the inner list (with the `context=""` parameter). Secondly, you have multiple images to capture so those wrapping tags need to be inside the custom field tag pair. Thirdly, it's good practice to try to capture only values - not markup - when setting variables and lists. Decoupling the capturing/presentation of a set of data like that makes it much easier to change the way that data is presented, permits reuse and aids legibility.

```
{exp:stash:set_list name="photos-list" parse_tags="yes" parse_depth="2"}
  {exp:channel:entries channel="photoblog" limit="5" orderby="" disable="member_data|pagination|categories" dynamic="no"}

      {stash:entry_id}{entry_id}{/stash:entry_id}
      {stash:title}{title}{/stash:title}
      {stash:description}{description}{/stash:description}

      {exp:stash:set_list:nested name="photos-image_{entry_id}" parse_tags="yes"}
          {photos}
             {stash:image}{image}{/stash:image}
          {/photos}
      {/exp:stash:set_list:nested}

  {/exp:channel:entries}
{/exp:stash:set_list}

{exp:stash:get_list
  name="photos-list"
  orderby="entry_id"
  sort="asc"
  limit="5"
  prefix="outer"
}
    <div id="pg_preview">
      {exp:stash:get_list:nested name="photos-image_{entry_id}" prefix="inner"}
          <img class="pg_thumb" {if inner:count==1}style="display:block;"{/if} src="{image}" width="1000" height="714" alt="{title}" />
      {/exp:stash:get_list:nested}
    </div>

    <div id="pg_desc1" class="pg_description">
      <div {if outer:count=="1"}style="display:block;"{/if}>
        <h2>{title}</h2>
      </div>
    </div><!--pg_desc1-->

    <div id="pg_desc2" class="pg_description">
        <div {if outer:count=="1"}style="display:block;"{/if}>
          {description}
          <a href="#" class="more">Details</a>
        </div>
    </div><!--pg_desc2-->

{/exp:stash:get_list}

```

There is an example of nesting lists in the docs too: https://github.com/croxton/Stash#example-usage-5-nesting-yep-you-really-can-do-this

---
Tags: stash
---


# Question
Title: How can I validate against a minimum number of words in a safecracker textarea?
I have a working safecracker entryform. My client would like visitors to write at least X words before submitting the entry.

I would like to show the number of words a visitor has typed in real time (on key up). Once the amount of words has reached X the visitor should be able to submit the entry.

I've looked at the docs: http://ellislab.com/expressionengine/user-guide/modules/safecracker/index.html#form-validation. They pointed me to http://ellislab.com/codeigniter/user-guide/libraries/form\_validation.html#rulereference. The closest rule I found is: min\_length. This only gives me a char count.

I'd like to be able to validate by number of words.

# Answer
> 0 votes
If it's on keyup, you need to handle it in the browser, with jQuery.

There are two jQuery plugins here. If validating on word count is not supported, you can write custom validation functions for either. You'd want to leverage what they're doing for validating minimum character length, split on spaces, and then get the length of that array. The length of the array would be the number of words.

It sounds like you're looking to do more than just validate, though –

> I would like to show the number of words a visitor has typed in real time (on key up).

Validate implies that there would be an error message when you tab out of the field (onblur) or submit the form (onsubmit). You might need to do a bit more work than just leverage the validator plugin to display the current word count as the user is typing.

---
Tags: safecracker, validation
---


# Question
Title: Forum Registration where submit also sends info Campaign Monitor
I have a client who would like to have members register for the discussion forums and when the user submits the form if they selected the checkbox to recieve a newsletter the form would both register the member (save info to EE) and submit their name, email and phone number (not sure if CC takes phone numbers) to campaign monitor.

First question - is it possible to have one form that submits to two different action urls? If so what would be the best way to set this up in the forum templates? I'm using a modified scaffold theme.

Second - assuming this can be done the next step involves getting the email, name and phone inputs to be used for both forms. The issue I see here is that the inputs have different names for the EE end and for Campaign Monitor.

# Answer
> 1 votes
We've submitted form data over to SalesForce using PHP in an extension called on Freeform's post submit hook. The same would apply here. I suspect you want the member\_member\_register hook.

Just write your extension to fire on that hook, and you can work with the API however you need to. You'll load data from the member database, and post it over to Campaign Monitor.

That said, there are a bunch of add-ons that claim to post new members to Campaign Monitor. Have you examined those?

---
Tags: members, forum, registration
---


# Question
Title: Preserving Pixel & Tonic Fieldtype Settings After Migrating to EE2
I'm in the process of migrating a site from EE1 to EE2. I successfully upgraded to EE2, but all the P&T addons (Matrix, Wygwam, Playa & Field Pack) seemed to default to either `text`, `select`, `ftype_id_X`, or `wysiwyg` under the `field_type` column.

How can I successfully update and preserve the fieldtype settings? I didn't see any docs specific to migration with these addons.

I noticed a `ff_settings` column in the `exp_channel_fields` table, but `NULL` value in the `field_settings` column?

When I go to edit a field group, I get theses errors (see attached). They Wygwam fields are blank in the type column?

Thanks for the help.

### Wygwam Update

Wygwam fields were easy to update, I just ran a query in the DB:

```
UPDATE exp_channel_fields SET field_type = 'wygwam' WHERE field_type = 'wysiwyg'

```

### Playa Update

All playa fields are text inputs right now that, which have data stored like:

```
[101] Title 1[102] Title 2

```

If I update the field settings to Playa with the correct filters, no entries are selected in the right pane of the multi-select.

# Answer
Each of our EE2 add-ons include a script that gets run during installation, which will attempt to determine if its EE1 counterpart used to be installed, and migrate all of the old settings and data.

So all that you should need to do is upgrade to EE2 and then install the EE2 versions of our add-ons.

If that didn’t work for you, chances are you tampered with the old exp\_ff\_fieldtypes table, or edited your field settings before installing the add-ons. I'd suggest that you re-attempt the EE2 upgrade, and go straight to installing the P&T add-ons before doing anything else.
> 2 votes

---
Tags: matrix, playa, wygwam
---


# Question
Title: set_flashdata with save_settings for extensions
After saving an extension's settings, EE by default redirects you to the Extensions landing page. I want to keep the user in the extension settings after saving but also use EE's flashdata.

The below code is in my save\_settings method.

```
$this->EE->session->set_flashdata('message_success', $this->EE->lang->line('preferences_updated'));
$this->EE->functions->redirect(BASE.AMP.'C=addons_extensions'.AMP.'M=extension_settings'.AMP.'file=my_custom_extension');

```

Does anyone know why set\_flashdata does not seem to work after the redirect where in Module settings this does?

I've also looked into this help request: displaying a flash message after redirect

# Answer
To do that you'll have to, I think, create the custom settings form for the extension. Once you have that, you'll also have to run custom processing so you'll have complete control of the redirect. Take a look at the extension docs for details. For a complete example, take a look at the EE Debug Toolbar settings code.
> 1 votes

---
Tags: add-on-development, extension
---


title: Wrong Entry Being Displayed?

text:
# Question
Title: Wrong Entry Being Displayed?
I have a trainer directory that seemed to be displaying fine but now I have more than 1 entry it will just display the content for **trainer1** even if im on the page for **trainer2**.

So **/personal-trainer-directory/trainer3/** is displaying the content for **/personal-trainer-directory/trainer1/** even though the URL says **/personal-trainer-directory/trainer3/**

here is how i have the template file setup. It’s a directory template file with Trainer Directory Search, Trainers Page, Gym Directory Search, Gyms Page:

```
{if segment_2 =="personal-trainer-directory" AND segment_3 ==""}
trainer search page
{if:else}
trainers page
{/if}

{if:elseif segment_2 =="gym-directory" AND segment_3 ==""}
gyms search page
{if:else}
gyms page
{/if}

```

Here is the code for **trainers page**: http://d.pr/n/OXg0 its a bit long so uploaded to droplr.

Been trying to figure this out for a couple hours and a bit stumped

# Answer
> 4 votes
Unless you are manually coding the url's, you want to remove the `dynamic='no'` parameter. This will allow either the `entry_id` or `url_title` to be used to pull the correct record. Dynamic 'no' overrides that, and requires that you tell the page, where to pull data to display a record entry.

---
Tags: channel-entries, templates
---


# Question
Title: Control Panel won't login on one single computer
ExpressionEngine 2.5.2 site. I can login as me (super admin) and my client (non-super admin) on several browsers on my computer, and from iPad and iPhone via LTE, and my client could login on her old laptop. At the same location on her new laptop, she can't login. I stopped by and couldn't login as me or her on her computer, using IE9 or Chrome. Checked cookies, they are on, and working, but none get set on the Control Panel login page and it reloads the login page with no error. Caches cleared, cookies cleared, browser and computer restarted. I'm puzzled.

# Answer
Chad, if you are in South Africa (SA?) then I strongly suspect you have an ISP (Telkom) / proxy related problem - something that has given me a few grey hairs in the past. Try setting "Require IP Address and User Agent for Login?" to off under Admin \> Security and Sessions and set Control Panel Session Type and User Session Type to cookies only.
> 2 votes

---
Tags: control-panel
---


# Question
Title: Apply shipping costs calculation before checkout
I've set up shipping methods in Store which have rules of "Country" and "Region" set to "(any)" but when I'm displaying my cart, the shipping costs are not included until the shipping address is set.

As I want to have shipping costs that don't rely on location, would it be possible to make Store apply the shipping costs matching this situation ?

# Answer
Shipping costs will still be calculated even before your cart has a shipping address (assuming some rules match). Are you sure this isn't just a problem with your template? (e.g. displaying `{order_subtotal}` instead of `{order_total}`?

Normally even if your shipping costs do depend on a region, you would set a default country and region under Store \> Settings \> Countries & Regions. This means shipping costs can be calculated before the customer adds their address.
> 1 votes

---
Tags: expresso-store
---


# Question
Title: Can I edit an existing order in Expresso Store?
Is it possible to edit a person's order through the backend? For example, if I need to correct a person's name or address or want to change a product in their order.

Thanks

# Answer
> 3 votes
There is no built in way to do this from the Store CP. You would need to edit the orders directly in the database (keep in mind this won't recalculate order totals if you change the items/shipping charges).

The best way to do this would be to write a simple module to let you update the order. I believe someone may already be working on a third party module to let you do this. I've also just added it to our feature requests page, so feel free to add your support.

---
Tags: expresso-store
---


# Question
Title: Change H3s into H2s + H4s into H3s for entries in specific channels in one-go
For a while the site editors have been using the wrong HTML headings (to get headings to look "right" instead of asking for the style sheet to be modified).

We have hundred of entries (in two specific channels) which we need to go over so headings that have been marked up as H3 are changed to H2, and headings marked up as H4 are changed to H3. The headings are in the body field as part of the main content for the entries.

Is there an automated way of doing this?

Thanks

# Answer
> 8 votes
Personally, this is where I'd just open Sequel Pro and run the database queries directly. But if you aren't use to working directly with the database tables or performing SQL queries directly, then ExpressionEngine provides a very simple and easy to use tool. But… **PLEASE BACKUP YOUR DATABASE FIRST**.

EE2 offers under the `Tools` Menu, the Search and Replace Tool.

The type of find you are doing is relatively simple. So basically, you will open the tool: Place

```
Search For: <h2>
Replace With: <h3>

```

Then select which field that you want to do the find and replace on, from the database list

Then perform the search. Now remember you need to do this for opening and closing tags, so don't forget the

```
Search For: </h2>
Replace With: </h3>

```

But just do this for each tag you need to replace. In fact, this tool, is perfect for this type of modifications. But it is powerful. So, please **backup** your database first, in case you *select the wrong field, modify a template instead of a field,* etc.

# Answer
> 3 votes
Copy the table in the database first, and then use a SQL query to test things out and directly manipulate data in the table.

It should be fairly easy if only straight tags have been used
e.g. `<h3>foobar</h3>` and not ``
goobar
`

Be careful in which order you search-replace `</h3><h3></h2><h2>` because you don't want to first replace all h4 to h3 and then replace the just replaced h3.

*Happy Query-ing*

---
Tags: channel-entries, entries, regular-expressions
---


title: Adding status to a query not working

text:
# Question
Title: Adding status to a query not working
Ive been using a query to pull in the amount of posts from a given category no problem. But i now want to pull in from a given status but no matter what i try its just not working quite right.

This is the code that works without the status..

```
{exp:query sql="SELECT count(exp_category_posts.entry_id) AS post_count

FROM exp_category_posts

WHERE cat_id = {category_id}
"}{post_count}{/exp:query}

```

And i want to add in the status.. which ive tried with the following, but this isnt quite right,

```
{exp:query sql="SELECT count(exp_category_posts.entry_id) AS post_count

FROM exp_category_posts

JOIN exp_channel_entries

WHERE cat_id = '{category_id}' AND status = 'open'
 "}{post_count}{/exp:query}

```

Anyone any suggestions?

thanks B.

# Answer
A `JOIN` requires an `ON` clause too. Also, it's `exp_channel_titles`, not `exp_channel_entries`. Try this on for size as the `sql` parameter:

```
SELECT COUNT(cp.entry_id) AS post_count
FROM exp_category_posts cp
JOIN exp_channel_titles t
ON cp.entry_id = t.entry_id
WHERE t.status IN ('Open', 'open')
AND cp.cat_id = '{category_id}'

```

If you want to add more statuses to the list, just add them inside the brackets, ie `('Open', 'open', 'draft', 'foo')`.
> 5 votes

---
Tags: categories, query, status
---


# Question
Title: Some pages giving errors and not loading after migration
I recently migrated my localhost EE website to a remote Linux server. Now, a few (5 out of about 35) of my pages are returning this error (Google Chrome for Win7):

> No data received. Unable to load the webpage because the server sent no data. Here are some suggestions: Reload this webpage later. Error 324 (net::ERR\_EMPTY\_RESPONSE): The server closed the connection without sending any data.

In Firefox for Windows, the error is:

> The connection to the server was reset while the page was loading.

The behavior is intermittent on some of the pages. Sometimes you can refresh the page several times and get it to load.

I am using Structure 3.3.8 as well as Low Variables, CE Image, Assets, and other add-ons.

Has anyone seen this problem before? Any ideas what's going on? Thanks.

### UPDATE

I tried deleting one of the page entries and recreating it. The new page has the same error.

I have put in a support ticket with my web host to see if they can review the server logs to find any clues.

# Answer
> 0 votes
Okay, at long last, my site appears to be working correctly. I corresponded with our web host, and they told me that I did not in fact have to include the "/~user" on the URL's for the site. I removed that and my previously broken pages are now loading correctly.

In other words, I was using a base URL of the form: `http://numericIP/~user/` (as specified in the welcome email for the hosting account) but should have been using `http://numericIP/` instead.

Thank you, everyone, for your efforts to help!

# Answer
> 1 votes
It might be PHP memory. Try the following in your .htaccess file:

```
php_value memory_limit 128M

```

**Updated:** If this definitely improves some of them, you might need to keep bumping it up. Try 256M. You're throwing a solution at the problem to see if it fixes it. If so, it's a performance issue in those templates. You can try turning on the Template Debugger or Output Profiler to see what you can find as well, on the pages that will load.

---
Tags: migration
---


title: Watermark using ImageMagick

text:
# Question
Title: Watermark using ImageMagick
I have a rather unique problem.

We're using EE to apply Watermarks to images on Upload & EE is using GD2 for doing this, which coincidentally is "washing-away" the rich colors of the original uploaded image. **What we would like for EE to do is use ImageMagick to apply Watermarks.**

We've reported this as a Bug on EE and we've received some thoughts on it:

1. EE won't be looking into this anytime soon
2. There's a way to achieve this manually

**Specific Question:** Has anyone found a solution to this problem? —If not, anyone with a knowledge on how to go about this (especially EE's support suggestion from my discussion with them below).

https://support.ellislab.com/bugs/detail/19036

# Answer
You have three options here:

1) You can hack your core EE files & change the PHP code to use Imagick rather than GD2 when doing watermarks. This may be the quickest code fix, but you'd have to track your changes to those core files whenever you do upgrades or troubleshoot issues.

2) You can write your own, simple plugin that takes an image as a parameter and processes it with Imagick to your satisfaction, returning the new image that you've saved to the filesystem.

3) You can see if CE Image \- a fantastic add-on I've relied on in multiple projects - does a better job. It does support adding watermarks.

**Updated:** I'm guessing you'll start in `system/codeigniter/system/libraries/Image_lib.php` for #1.
> 1 votes

---
Tags: image
---


# Question
Title: Output pages module 'nested pages' for navigation?
I have a number of sites using the plain vanilla native 'Pages' module in EE where I would like to output a simple 'child pages' list for pages with children (based on the page\_uri).

In the Pages module itself pages are displayed with nesting so I'm guessing the data is there somewhere - but how to get at it?

I'm not adverse to writing a plug-in but could do with some guidance on ow the pages module knows what's a child of what?

Update: I think what I'm looking for is an EE2 version of Mark Huots plag-in for the original pages module - http://devot-ee.com/add-ons/pages-nested-menu

Update: Using the EE1.x \> EE2.x upgrade instructions I've managed to get a version of this plug-in working for EE2.x. It's still a little rough around the edges but it's better than nothing!

https://github.com/ninefour/pages\_nested\_menu.pi.ee\_addon

# Answer
A plugin is definitely required here. Unfortunately, the Pages module doesn't store data in a hierarchical format, and the logic used in the module control panel is not ideal for use as a plugin (as you need a properly nested array for that). So you're starting from scracth.

But here's something to get you started: all pages are stored in `$this->EE->config->item('site_pages')`, as an array with site\_ids as keys, and then further arrays with entry\_ids as keys and page URIs as values. So you'll need to query the titles for each.

Here's some quick starter code:

```
$pages = $this->EE->config->item('site_pages');
if ($pages === FALSE OR count($pages[$this->EE->config->item('site_id')]['uris']) == 0)
{
    return false;
}

$pages = $pages[$this->EE->config->item('site_id')]['uris'];
natcasesort($pages);

$titles = array();
$entry_ids = array_keys($pages);
$entry_ids = implode(',', $entry_ids);

$titles_q = $this->EE->db->query("SELECT entry_id, title FROM exp_channel_titles WHERE entry_id IN($entry_ids)");
if($titles_q->num_rows() > 0)
{
    foreach($titles_q->result_array() as $entry)
    {
        extract($entry);
        $titles[$entry_id] = $title;
    }
}

print_r($pages);
print_r($titles);

```

So this gives you two arrays, both with the entry\_id as a key, and one with the URI as the value, and another with the Title as the value. From here you'll need to do some sorting, explode the URI values using a forward slash as a delimiter, and build a new array, etc. Lots of array juggling to build this with a proper hierarchy, and in the order you want it.

In the end, you want to end up with something like this (to pass to `$this->EE->TMPL->parse_variables`):

```
$pages = array(
    [0] => array(
        'entry_id' => XX,
        'title' => 'About Us',
        'uri' => '/about',
        'children' => array(
            [0] => array(
                'entry_id' => XX,
                'title' => 'Staff',
                'uri' => '/about/staff'
            ),
            [1] => array(
                'entry_id' => XX,
                'title' => 'History',
                'uri' => '/about/history'
            ),
        )
    ),
    [1] => array(
        'entry_id' => XX,
        'title' => 'Location',
        'uri' => '/location',
        'children' => ''
    )
    [2] => array(
        'entry_id' => XX,
        'title' => 'Contact Us',
        'uri' => '/contact',
        'children' => ''
    )
);

```
> 1 votes

---
Tags: navigation, pages
---


# Question
Title: How do I check if a field value has changed in a entry_submission_ready hook handler?
I am writing an extension for the hook

```
entry_submission_ready

```

I see that it has 3 params(meta, data, autosave).

I look at data and I see there is channel data in there and a revision post data index.

I assumed that the revision post data contains the old, not updated data.

But when I compared then to the top level data, they are the same. Both also show the updated data.

Is there any way I can access the old data? Do I need to use a different hook?

How do I know if a field value has been changed by edits?

# Answer
That hook gives you all the data you need to query the database. `$meta` will hold your `entry_id`, `channel_id`, `title`, etc (anything that goes in `exp_channel_titles`), and `$data` holds your custom field data.

So just as an example:

```
if(!empty($meta['entry_id']))
{
    $current = $this->EE->db->query("
        SELECT * FROM exp_channel_data WHERE entry_id = {$meta['entry_id']} LIMIT 1
    ");
    if($current->num_rows() == 1)
    {
        if($data['field_id_1'] === $current->row('field_id_1'))
        {
            // Data has not changed in field_id_1
         }
    }
}

```
> 4 votes

---
Tags: hook
---


# Question
Title: Channel Entries pulled through to a site footer
The footer of my site needs to pull through the 6 most recent Case Studies. Here is the code, embedded in a template file for the footer of the site:

```
<li><strong>Case Studies</strong></li>
{exp:channel:entries channel="case_studies" limit="6"}
    <li><a href="{path="case_studies/case_study/{url_title}"}">{title}</a></li>
{/exp:channel:entries}

```

Nice and simple, right?

This works perfectly on my homepage and under *some* URLs, but not all of them. For example, when I visit http://example.com/about/latest\_news it will appear, as will http://example.com/press\_articles/ \- but http://example.com/services doesn't.

Is there anything obvious setting or reason for this?

Thanks!

# Answer
> 4 votes
Yep, add `dynamic="no"` parameter to the `channel:entries` tag :)

# Answer
> 1 votes
This is easy: You need `dynamic="off"` on your `exp:channel:entries` tag.

EE automatically filters entries based on the URL, expecting that to contain entry IDs or URL Titles.

---
Tags: channel-entries, templates, channel
---


# Question
Title: How to automatically populate fields based on the value in another field
I've got three custom dropdown fields - town, county, and region in a SafeCracker form. The client is asking if it's possible for them to just select one value (in the town dropdown field), and for the other two to pre-populate with the correct county and region. I do have a spreadsheet of town names that has the region and county for each town.

I've searched for add-ons that might do this but haven't managed to find any, so just wondering if there are any recommendations on how to go about doing this in a SafeCracker form? I'm not even sure what fields I'm best using, or whether this needs to be done outside of EE completely? Thanks in advance for any advice on this.

# Answer
> 4 votes
Typically you'll do this sort of thing by writing some jQuery code and storing that in the `Instructions` field of one of your field's definitions. That field supports HTML, so anything inside a `<script/>` tag will run when the page runs.

You can then set up an onchange event handler that updates the other fields when the primary field is changed.

To make this flexible, I'd recommend creating channels for your towns, regions and counties. That way they can be maintained by the client. You can use AJAX to query the database (using a custom template as the AJAX URL), so that when a town is selected, it finds the corresponding county & region in the database, and updates the corresponding fields accordingly.

# Answer
> 3 votes
Since you only want to let your visitors choose the town, and you already know which region and county each town belongs to, why not make the "towns" field a Relationship or Playa field, and relate it to a "Towns" channel, which has the Region and County data stored there as channel fields?

The user never needs to see this additional (Region, County) info on the front-end (so no javascript or AJAX required), but the data is there for use in your templates and by your client.

---
Tags: safecracker, pre-populate
---


# Question
Title: {filedir_X} tag not parsing in File field
I have a link to an uploaded PDF in my template but some of links seem to output a mystery {filedir\_3} instead of the path to the upload folder.

So the following template code...

```
{if download_details}<a href="{download_details}" target="_blank">Download details »</a>{/if}

```

outputs as...

```
<a href="{filedir_3}blahblah.pdf" target="_blank">Download details »</a>

```

This seems to be occurring on new files and older uploaded files don't seem to be effected. I had a look at the database and the exp\_files table doesn't show any obvious different between working and broken links. I upgraded to EE 2.4.0 recently, could this be the issue? I'm not using MSM and the files aren't being uploaded through RTE or wygwam, just through a file channel field.

# Answer
> 4 votes
Just wanted to mention that parse file paths by Rob Sanchez will parse `{filedir_X}` variables. Usage below:

```
{exp:parse_file_paths}
    {filedir_X}
{/exp:parse_file_paths}

```

To be used with query module, activerecord plugin, and any other add-on that outputs raw channel data.

Since your problem was that a plugin was outputting raw results from the DB, it looks like it would be the perfect fit and would allow you to get rid of that PHP code

# Answer
> 1 votes
In the end I found it was wrapped in a custom plugin which was taking the results directly from the exp\_channel\_data table. I'm not sure why EE suddenly decided to stop parsing filedir\_3 but I added the following if statement into the code as a bit of a bodge and it's working fine now.

```
for($i=0;$i<$data_row_count;$i++) { // for every row
    ..SNIP...
    if (isset($vars['download_details']))
        $vars['download_details'] = str_replace('{filedir_3}','/uploads/',$vars['download_details']);
    $variables[]=$vars;
}
return $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $variables) ;

```

---
Tags: file-uploads, parsing
---


# Question
Title: "Invalid Member" error when trying to edit profile using Profile:Edit
I'm using Profile:Edit for a site running EE 2.5.5. Logged in as Super Admin when I try to edit the account/profile info I get the following error:

```
The form you submitted contained the following errors

- Invalid member

Return to Previous Page

```

Here's my code:

```
{exp:profile:edit return="members"}
                    <fieldset>
                        <p class="profile-row">
                            <strong>Username</strong> <span><input type="text" name="username" value="{username}" /></span>
                        </p>

                        <p class="profile-row">
                            <strong>Email</strong> <span><input type="text" name="email" value="{email}" /></span>
                        </p>
                    </fieldset>

                    <fieldset>
                        <p><strong>Note:</strong> Leave blank if you do not wish to change your password.</p>

                        <p class="profile-row">
                            <strong>New Password</strong> <span><input type="password" name="password" value="" /></span>
                        </p>

                        <p class="profile-row">
                            <strong>Confirm New Password</strong> <span><input type="password" name="password_confirm" value="" /></span>
                        </p>

                        {!-- superadmins don't have to submit existing password --}
                        {if logged_in_group_id != 1}
                            <p class="profile-row">
                                <strong>Your Existing Password<br /><em>(You must submit the current password to update this page)</em></strong> <span><input type="password" name="current_password" value="" /></span>
                            </p>
                        {/if}
                    </fieldset>

                    <fieldset>
                        {custom_fields}
                            <p class="profile-row">
                                <strong><label for="{field_name}">{field_label} {if required}*{/if}</label></strong>

                                {!-- {field_instructions}

                                {formatting_buttons} --}
                                <span>
                                    {if textarea}<textarea id="{field_name}" name="{field_name}" dir="{text_direction}" rows="{rows}">{field_data}</textarea>{/if}

                                    {if text}<input type="text" dir="{text_direction}" id="{field_name}" name="{field_name}" value="{field_data}" maxlength="{maxlength}" />{/if}

                                    {if select}
                                        <select id="{field_name}" name="{field_name}">
                                        {options}<option value="{option_value}"{selected}>{option_name}</option>{/options}
                                        </select>
                                    {/if}

                                    {if date}<input type="text" id="{field_name}" name="{field_name}" value="{field_data}" />{/if}

                                    {if checkbox}
                                        {options}<label class="checkbox">{option_value} <input type="checkbox" id="{field_name}" name="{field_name}[]" value="{option_value}"{checked} /></label>{/options}
                                    {/if}

                                    {if radio}
                                        {options}<label class="checkbox">{option_value}<label class="checkbox"> <input type="radio" id="{field_name}" name="{field_name}" value="{option_value}"{checked} /></label>{/options}
                                    {/if}

                                    {if file}{display_field}{/if}

                                    {if relationship}
                                        <select id="{field_name}" name="{field_name}">
                                        {options}<option value="{option_value}"{selected}>{option_name}</option>{/options}
                                        </select>
                                    {/if}

                                    {if multiselect}
                                        <select id="{field_name}" name="{field_name}[]" multiple="multiple">
                                        {options}<option value="{option_value}"{selected}>{option_name}</option>{/options}
                                        </select>
                                    {/if}
                                </span>
                            </p>
                        {/custom_fields}
                    </fieldset>

                    <fieldset>
                        <input type="submit" value="Save" />
                    </fieldset>
                {/exp:profile:edit}

```

Has anyone seen this or know how to troubleshoot & fix? Is the member ID or entry ID needed in the URL (currently not there as the docs say it's not necessary)?

(If I edit in the back-end via the member channel entry, it works fine.)

# Answer
So after poking through the module's code I was able to narrow it down to being a DB issue. For whatever reason, there was no row for the member in the `exp_member_data` table. I have no idea why it wasn't there, but adding it in did the trick (super simple since that table has only one column).

If anyone has any idea why the member ID wouldn't be in that table, I'd love to hear it. Thanks!
> 1 votes

# Answer
If you are logged in as Super Admin, but are editing a different profile, I believe you will need that entry\_id. Have you tried adding it and seeing if it works? Otherwise it's pulling it via the logged\_in\_member\_id I think, IIRC.
> 0 votes

# Answer
I believe I ran into something similar before. Here's a few things I would try. Since Profile:Edit utilizes SafeCracker, I would try setting these parameters.

In the SafeCracker documentation it says the channel parameter is required. http://ellislab.com/expressionengine/user-guide/modules/safecracker/index.html#channel

channel="\[your\_profile\_edit\_channel\_name\]"

I remember setting author\_only to "yes" did the trick.

author\_only="yes"
> 0 votes

---
Tags: ee2, members, profile-edit
---


# Question
Title: Renaming image files upon upload.. Channel Images?
I have a gallery on each of my single entry pages, that includes image files uploaded by my users.

Is there a way to automatically change the filenames of these images upon upload? Something like `IMG1074.jpg` to `entry_title_001.jpg`?

I'm outputting the images via CE image, and I have tried the `filename=` parameter, but that renames all the images within the gallery to the same filename.

# Answer
If there's something unique per-image in the Channel Images output (assuming your gallery is just a dump of all images assigned to the field), you should be able to append that unique value to your `entry_title`, right?

```
filename="{url_title}_{image:id}"

```

It's not something I've done, but I'm assuming you can do more with the `filename` parameter to make those filenames unique.

I think this solution was successfully applied in this question: Renaming image file names.
> 3 votes

---
Tags: file-uploads, image, channel-images
---


title: Using pagination with filtered entries

text:
# Question
Title: Using pagination with filtered entries
I am filtering a list of entries using an {if…} conditional, but the exp:entries tag outputs the count for the total number of entries before the conditional is applied. And as I am using pagination I end up with a wrong number of pages. Does anyone know if there is an easy way to fix this?

My code looks something like this:

```
   {exp:user:users group_id="9|10|11" orderby="lastname" sort="asc" limit="300" paginate="bottom" }

    {if location_area =="{segment_3}"}
     {title}
    {/if}

{user_paginate}
Page {user_current_page} of {user_total_pages}   {user_pagination_links}
{/user_paginate}

{/exp:user:users}

```

As you can see I'm using the Solspace User addon.

Thanks for any help.

Andrew

# Answer
You'll want to change your conditional to be a `search` parameter filter.

```
{exp:user:users ... search:location_area="{segment_3}"

```
> 3 votes

---
Tags: conditionals, pagination, solspace-user
---


# Question
Title: How to convert MH File Field's with multiple images?
Anyone successfully convert MH file fieldtype that has multiple images to a matrix or similar? I have some entries that have multiple images tied to a single MH file field. I'm in the process of upgrading EE1 to EE2, and fields with just one image are fine, but entries with multiple images have data stored like:

```
image_1.jpg
image_2.jpg

```

I've seen these threads for after upgrading to EE2 for nGen file field and MH file field, but these are specific to single files.

# Answer
All credit goes to Brandon. I searched and found this **thread** last night which was ultimately the solution. I'll post the script below as that thread was a little confusing to follow until they got it working.

You'll need to convert all MH File fields to a Matrix field first. Then run the script below.

> Make sure to replace XX with your Matrix field ID, YY with your File column ID, and ZZ with your file upload directory ID.

```
<?php

    // Converts Mark Huot's File Field with multiple images to a Matrix column
    mysql_connect("localhost", "db_username", "db_password") or die(mysql_error());
    mysql_select_db("database_name") or die(mysql_error());

    $query = mysql_query('SELECT site_id, entry_id, field_id_XX FROM exp_channel_data WHERE field_id_XX IS NOT NULL');
    while ($row = mysql_fetch_assoc($query)) {

        // get the file names
        $files = array_filter(preg_split('/[\r\n]/', $row['field_id_XX']));

        // add them to exp_matrix_data
        foreach ($files as $i => $file) {

            mysql_query('INSERT INTO exp_matrix_data (site_id, entry_id, field_id, row_order, col_id_YY)
            VALUES ('.$row['site_id'].', '.$row['entry_id'].', XX, '.$i.', "{filedir_ZZ}'.$file.'")');
        }
    }
?>

```
> 3 votes

---
Tags: matrix, migration
---


title: Agressive template caching in EE1

text:
# Question
Title: Agressive template caching in EE1
I've got an old EE1 site that I'm doing some minor updates to but I'm finding that it is very aggressively caching embedded templates.

This means that when I make a change it doesn't appear on the site until I clear the Template (page) Cache in the control panel.

Is there a setting somewhere to restrict this behaviour?

# Answer
It sounds like some of those templates have cache enabled? Did you check the template preferences?

Go to **Templates \> Choose Template Group \> Click Preferences \> Here you can adjust template settings**
> 2 votes

---
Tags: templates, ee1, embeds, caching
---


# Question
Title: Conditional display of fields in CP entry screen, based on other fields' value/state
Is it possible to show / hide certain form fields on an entry page depending on whether or not, say a checkbox is selected? Hoping for an add-in that can handle this.

# Answer
Since you're only concerned with showing/hiding fields based on user choice, the **Entry Type** add-on would do the trick. It is "a dropdown fieldtype that shows/hides other fields on the publish page" based on the chosen option.
> 2 votes

# Answer
This has been covered here and here.

I'm not sure that it's similar enough to those to be a duplicate, as they specifically sought to change other fields values, or show/hide fields based on entry ID, but the same technique is used.

You can story jQuery/JavaScript in the Instructions field for one of your fields. That will render HTML, including the contents of a `<script/>` tag.

In that `<script/>` tag, you can use jQuery to show/hide the other field based on the value of the checkbox field and an onchange event.
> 1 votes

---
Tags: add-on, conditionals, entry
---


title: Comment Wont Appear

text:
# Question
Title: Comment Wont Appear
I copied my comment forms directly from my blog posts so I can use them also for comments on trainer pages but the same code that was working before wont work with my new channel.

Link to example (droplr)

Is there anything I'm forgetting to get this to work? If I remove the channel variable from both, nothing will change with the comment:entries, but comment:form will display. I can't seem to get these to display with the **personal\_trainer\_directory** channel

Current Channel Settings

# Answer
Sounds like the form doesn't know which entry to associate the comment with.

Try setting either the `entry_id=""` or `url_title=""` parameters on the `{exp:comment:form}` tag.
> 2 votes

# Answer
Joe,

You'll need to make sure that comments are on for that channel, and that you're visiting that page as a Single Entry page. That is, where the URL contains either the Entry ID or URL Title of an entry that allows comments.
> 0 votes

---
Tags: channel-entries, comments, comment-form
---


title: Upgrade "stuck" between 2.2 and 2.5

text:
# Question
Title: Upgrade "stuck" between 2.2 and 2.5
I'm doing an upgrade of a site from 2.2.x to 2.5.5. I've moved all of the files up, and prepped for the upgrade but when I run the upgrade wizard it is literally stuck on this screen: http://cl.ly/image/3r3L16453428

It will flash to say "Starting next step..." and then back to 2.3.0

Video is here: http://www.screencast.com/t/R7KzkLAld

Anyone else ever see this issue?

# Answer
> 1 votes
I've had the same thing happen. And my solution was just as you described - restarting the upgrade after seeing the progress stall out. It did seem very strange to have to resort to such methods. However, I haven't seen any problems with the sites upgraded that way. I've seen it happen on multiple hosting platforms too. I use DevDemon's Updater now and don't run into it anymore.

# Answer
> 0 votes
I had this issue. I **think** I managed to fix it by disabling javascript on my browser to stop the "ajax=yes" parameter.

However, I also switched back and forth between two browsers and cleared my page cache repeatedly. It was a bit of a process. :)

I would try seeing if disabling javascript fixes the issue first since that was my last step. This can be quickly enabled/disabled using the web developer extension. See: Web developer firefox or Web Developer Chrome

---
Tags: upgrade, ee2-upgrades
---


# Question
Title: How do I set a field value in entry_submission_ready hook handler?
It seems that changing the values of the $data argument variable doesn't change anything.

Is there a way to change the value of some channel fields inside the `entry_submission_ready` hook?

# Answer
> 3 votes
After tinkering around, I found out that the way to do it is to set these values inside the method

```
$this->EE->api_channel_entries->data['my_field_id'] = 'my_field_value';

```

---
Tags: channel, hook
---


# Question
Title: What's the configuration for multiple subsites the legacy way in ExpressionEngine?
Let me lead with a quote from the present EE license. "An ExpressionEngine license purchase allows a single “live” installation in a production environment and ancillary “development use only” installations as needed to support the live installation (such as development and a staging servers). Additional installations require additional license purchases."

Further, even if you buy the Multi Site Manager add-on, the license requirement is that "License holder must be the owner of all Sites" -- and there is a long-enforced blanket legal disapproval of subletting an EE license or creating any kind of blogging service.

So, we are talking only about how to arrange multiple subdomains or sites when you don't need all the features of the Multiple Site Manager, but follow rules as if you licensed it. This is the pre-existing, or 'legacy' multiple site mode which is still in use, and was guaranteed by Ellis to continue to be present.

Some later code was discussed and repaired so that it did indeed remain available, and this mode is particularly convenient when all you need is some subdomains for development and testing, or for simple multi-presentation from a singly-owned site, as in some number of older EE1 sites which are still in use, and need to be maintained or simply upgraded.

I'm going to answer my own question here, as I spent the time to resurrect a development site using this mode today for someone. I consider it another instance of bringing out into this public resource the community knowledge we all contributed in over prior years.

# Answer
These instructions lay out in brief the considerations for setting up a subdomain site in the form available at EngineHosting, where all domain accesses go to the main domain public\_html. On other hosts which use DNS to assign subdomains, you won't need the additions to the main domain .htaccess.

1. The EE install, where you have CP themes, etc., is at the root directory for web service: public\_html. It is important that it stay there, because of a change Ellis made in EE that broke updating capability from subdirectories. However, you can freely move the system folder where you like, adjusting your `index.php` path. I have it above public\_html, in the usual fashion.
2. Here’s the htaccess scripting that I use to enable a subdomain on a subdirectory of public\_html. YMMV, but this is straightforward, and again not needed if your host directly assigns subdomain directories.

In root .htaccess, above your scripting for the EE install there, and below RewriteEngine On, goes the following. It accomplishes redirecting subdomain web requests so that they appear to be direct on the subdirectory:

\# add the www if toplevel.com only; tell the browser always to use it

```
RewriteCond %{HTTP_HOST} ^(yoursite.*) [NC]
RewriteRule ^http://www\.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

```

\# pick off any subdomains to be handled in their own directory

```
RewriteCond %{HTTP_HOST} ^subdomain.yoursite.com [NC]
RewriteCond %{REQUEST_FILENAME} !subdomain/ # allows image requests etc. to pass through
RewriteRule ^(.*)$ ae/$1 [L]

```
3. In the subdomain’s subdirectory, you just put your standard .htaccess as if it were a top-level domain. In EE itself, be sure to check through the main level site’s CP path settings, just to make sure the installer was sensible. I find Deeploy Helper to be very helpful to assure such matters, besides its primary purpose.
4. You can initialize the subdirectory EE by copying over your main level’s index.php, adminasyounameit.php, and anything like favico or images directories that you want to use on the subdomain. As an EE site, the subdomain is independent of the domain-level site.
5. Here are the additions or changes I made to the results of such a copy:

In adminasyounameit.php, set your system path relative to the subdirectory:

```
$system_path = '../../de/system'; // for system in de folder above public_html

```

Now you can run admin normally from the subdomain website. There are probably tricks to get it to line up on the correct template group; haven’t bothered.

In index.php, also:

```
$system_path = '../../de/system'; // for system in de folder above public_html

```

This is what fundamentally enables your site

Now you want to set so correct template group is used for the subdomain. Must set initial template too, as created bugs here were resolved.

```
$assign_to_config['template'] = 'index';
$assign_to_config['template_group'] = 'subtemplategroup';

```

You likely want a separate 404 page for the subdomain; otherwise will get main domain’s

```
$assign_to_config['site_404'] = 'subtemplategroup/notfound';

```

The following form is handy if you do as I do, use global variables inside to site-specifically target generic templates to localize for many purposes

```
$assign_to_config['global_vars']
  = array("my_channel" => "subdomainchan", "my_template_group" => "subtemplategroup");

```

Set the site name so it shows correctly wherever defaulted

```
$assign_to_config['site_name'] = 'SubDomain Sitename’;

```

Let EE internals know where this subdomain is in the web url sense. This is crucial in having it emit items correctly which have paths auto-added, such as may be case for css, images, etc..

```
$assign_to_config['site_url'] = 'http://subdomain.yoursite.com/';

```

The CP theme will be handled automatically from what you config’d in the base EE install control panel, as the CP will be called just as if it were from the main site.

We are now just above ‘END OF USER CONFIGURABLE SETTINGS’ in index.php, and things should run on the subsite, once saving from here.

I hope this is quite readable if not perfectly formatted, after a bit of a fight with the StackExchange editor about indents vs. code blocks.
> 2 votes

---
Tags: subdomain, config, multiple-sites
---