# Question
Title: Cannot modify $item->modifiers in store_order_item_add_end hook
I have an extension using the store\_order\_item\_add\_end hook.

I can set field values such as $item-\>price and $item-\>weight - but I cannot change the content of $item-\>modifiers.

I've also tried going via the $order-\>items array.

I have an existing modifier value I need to update. I can read its contents fine - but any changes I make are never reflected.

# Answer
Apparently the key is to use:

$modifiers = $item-\>modifiers;

// modify the $modifiers data

$item-\>setModifiersAttribute($modifiers);

in the store\_order\_item\_add\_end hook.
> 1 votes

---
Tags: expresso-store, hook
---


title: Solspace Favorites - collection name

text:
# Question
Title: Solspace Favorites - collection name
We have the following code in our templates,

```
 {exp:favorites:info
 entry_id="{embed:entry_id}"
 disable_pagination="yes"
 }
 {exp:favorites:edit
 favorite_id="{favorites:favorite_id}"
 return="{embed:return_url}"
 form:style="display:inline;"
 error_page="favorites/ajax_error"
 }

 {favorites:collection}
 {/exp:favorites:edit}

```

{/exp:favorites:info}

Which works when we have an add or edit button, but if we want the collection name {favorites:collection} it simply spits out the curly braces:

# Answer
Sorry about that. The correct variable name should in fact be {favorites:collection\_name} when used with in the Favorites:Info tag. I have updated the documentation now :) http://www.solspace.com/docs/favorites/info/#favorites\_collection\_name
> 0 votes

---
Tags: solspace
---


title: UPS Shipping Extension Errors

text:
# Question
Title: UPS Shipping Extension Errors
When attempting to use the UPS Shipping Extension for Exp-resso store, the install runs fine, but when attempting to add anything to the cart on the front-end we get the message:

> A PHP Error was encountered
>
> Severity: Warning
>
> Message: call\_user\_func\_array() expects parameter 1 to be a valid callback, class 'Store\_ups\_ext' does not have a method 'store\_order\_shipping\_methods'
>
> Filename: libraries/Extensions.php
>
> Line Number: 262

I have attempted to uninstall and reinstall the UPS extension, the EE installation was newly installed prior to adding the UPS Extension.

We are using the following:

* EE 2.9.2
* Store 2.5.0
* UPS Extension 1.1.0

Thanks

Phil Dowson

# Answer
> 0 votes
There is an issue with the UPS v1.1 installer. If you install this extension without updating from a previous one the installer uses the wrong method. You will need to run this query to get things working.

```
UPDATE exp_extensions SET method = 'shipping_methods' WHERE class = 'Store_ups_ext';

```

---
Tags: ee2, expresso, ups-shipping
---


title: How to detect no grid entries

text:
# Question
Title: How to detect no grid entries
I've been trying to set up a conditional that will display a notification message if there are no entries in the grid. Like this

```
{if mygrid:total_rows != "0"}
<h6> Title </h6>
  {mygrid}
     <p>{mygrid:title}</p>
  {/mygrid}
{if:else}
<h2>ERROR</h2>
{/if}

```

However when there are 0 rows the conditional does not execute the ERROR message. I output {mygrid:total\_rows} and displays 0 for no rows and 1,2,3... etc if there are entries. If there are grid rows the grid content is displayed.

I'm not sure why the conditional won't execute {if:else}

Even something like won't execute

```
 {if mygrid:total_rows == "0"}
  <p> MESSAGE </p>
{/if}

```

# Answer
I've had very odd problems with grids and total\_rows, especially if you have multiple grid fields in the template with multiple conditionals throughout checking for total\_rows.

I tried numerous conditionals to get round the problem and oddly, something that would be working, suddenly stopped when adding another conditional in the template, which must be related to an EE conditional bug.

What seems to work consistently is:

```
{if mygrid:total_rows > 0}...{if:else}...{/if}

```

Another technique albeit clunky:

```
{if "{mygrid limit=1}has content{/mygrid}" != ""}...{if:else}...{/if}

```

If you still have issues, check other conditionals in the template.
> 1 votes

---
Tags: grid
---


title: FusionChart Issue

text:
# Question
Title: FusionChart Issue
Please find the below code for load fusionchart on my home page, here 'newurl' loading data.xml from fusionchart folder. This works fine and showing graph, but my issue that, i m trying to load xml page from 'templates-\>data-\>data.xml'

```
<script type="text/javascript" src="fusioncharts/fusioncharts.js"></script>
<div id="chartContainer">FusionCharts XT will load here!</div>

<script type="text/javascript">

  var myChart = new FusionCharts( "Column3D",
                "myid here", "400", "300", "0" );
  //  var newurl =  "datatest.xml";
  var newurl =  "fusioncharts/data.xml";
  myChart.setDataURL(newurl);
  myChart.render("chartContainer");

</script>

```

and the xml page (templates-\>data-\>data.xml )like ,

```
{exp:weblog:entries weblog="school" entry_id="{segment_3}" limit="1"}
{reverse_related_entries weblog="school_results" limit="1"}
    <graph bgAlpha='0,0' xAxisName='Parties (roll over the bars to see their names)' yAxisName='Seats' showNames='0' decimalPrecision='0' formatNumberScale='0' outCnvBaseFontColor='ffffff' outCnvBaseFont='Verdana' outCnvBaseFontSize='12'>
{results}
{if segment_4}
    {if "{row_count}" <= "{segment_4}"}
        <set name='{name}' value='{content}' color='{colour}'/>
    {/if}
{if:else}
    <set name='{name}' value='{content}' color='{colour}'/>
{/if}
{/results}
</graph>
{/reverse_related_entries}
{/exp:weblog:entries}

```

How can call this , i mean how can call the template file to script?

# Answer
Your data source needs to be a template you've created inside EE, it needs to be set as an XML template type, and it needs to know what entry to load.

So following your example, create a template group called `data`, then inside that template group create a template also called `data`, and use the template code you posted.

Then you could use `data/data/{entry_id}` as the value for the `newurl` variable in your javascript.
> 1 votes

---
Tags: ee1
---


# Question
Title: how can I redirect a homepage depending on the browser language settings
I would like to know what's the best method to redirect a site depending on the browsers language settings.

I want to redirect the following browser locales to /es:

es-ar, es-co, es-cu, es-do, es-gt, es-ht, es-mx, es-ni, es-pe, es-pr, es-sv and of course es and es-es

i know it could be done via .htaccess but the following did not work at all:

```
 RewriteCond %{HTTP:Accept-Language} (es|es-ec|es-mx|es-co) [NC]
 RewriteRule .* http://www.%{HTTP_HOST}/es/ [R,L]

```

but I think the best would be to do this in the index.php template:

in the /index.php I would need some sort of redirection upon language detection but my php skills are very limited, so maybe someone can show me the right path:

something like:

```
if ($_SERVER['HTTP_ACCEPT_LANGUAGE'] = "es|es-es|...")
{
    // header( 'Location: http://${_SERVER['HTTP_HOST']}/es/');
    //please help!
};

```

any help appreciated!

cheers
stefan

# Answer
> 0 votes
After looking on the interwebs I found a solution that suits my needs for the moment. I guess a real solution would involve cookies and some more checks.

I put this in the index.php file.

```
$lc = ""; // Initialize the language code variable
// Check to see that the global language server variable isset()
// If it is set, we cut the first two characters from that string
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
    $lc = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
// Now we simply evaluate that variable to detect specific languages
if($lc == "es"){
    header("location: /es");
    exit();
}

```

it's great, because it always checks for ALL of the locales (es-es, es...)! but it gets executed on every page load... this is certainly no good...

cheers stefan

btw: If somebody knows a better solution, please don't hesitate to post it... it's still not a 100% satisfactory for me.

# Answer
> 2 votes
This should do it:

```
$accept_language = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
$lang = $accept_language[0];
echo $lang;
switch ($lang)
{
    case 'en-US':
    case 'en':
        echo 'Success!';
        break;
    default:
        echo 'Count on En';
}

```

# Answer
> -1 votes
No cookies needed.

What I do is to redirect the homepage to the relevent language section of my site based on **HTTP\_ACCEPT\_LANGUAGE** only if the visitor is coming from a link external to my site or by typing the domain directly in the browser. I determine this by using **HTTP\_HOST** and **HTTP\_REFERER**.

So if he arrives externally on the homepage (english) with an italian browser he gets redirected to the italian section of my site. If he then clicks on the "english" link on that page he get's to see the "english" homepage without being redirected.

Here's the ASP code I use. It should be quite readable and easy to port into other programming languages.

```
strHTTP_HOST = request.servervariables("HTTP_HOST")
strHTTP_REFERER = request.servervariables("HTTP_REFERER")
strHTTP_ACCEPT_LANGUAGE = left(request.servervariables("HTTP_ACCEPT_LANGUAGE")&"",2)

If (GetDomainName(strHTTP_REFERER) <> GetDomainName(strHTTP_HOST)) And (strHTTP_ACCEPT_LANGUAGE="it") Then
  response.redirect "index_it.asp"
End If

Function GetDomainName(Domain)

  z = Domain
  If z <> "" then
    If InStr(z, "//") <> 0 Then ' take of http:// or http:// etc.
      z = Right(z, Len(z) - InStr(z, "//") - 1)
    End If
    If InStr(z, "/") <> 0 Then ' strip off paths
      z = Left(z, InStr(z, "/") - 1)
    End If
    If InStr(z, ".") <> InStrRev(z, ".") <> 0 Then          ' get 2nd leveldomain
      z = Right(z, Len(z) - InStrRev(z, ".", Len(z) - 4)) ' basically gets the location of the second point
    End If                          ' assumes that domain is at keast 2 chars !
  End If
    GetDomainName = z

End Function

```

---
Tags: redirects, multi-language
---


title: Hook for when status is updated

text:
# Question
Title: Hook for when status is updated
Is there a hook that could be used to check what status was before submission, and what status is submitted (changed to) whilst editing an entry?

I want to check to see if a status is changed to 'x2' from 'x1' for example.

Thanks

# Answer
I would use the

```
entry_submission_ready

```

extension hook, and write a mini-extension that looks at the meta array in the api for the entry status value, and compares it to the previous value for that entry (if it exists). Quick example hook function that could work for your situation:

```
function entry_submission_ready_my_hook($meta, $data, $autosave)
{
    // get entry_status and entry_id if it exists
    $new_status = $meta['status'];
    $entry_id = $data['entry_id'];

    // check if the entry exists
    $entry = ee()->db->select('status')
                 ->from('channel_titles')
                 ->where('entry_id', $entry_id)
                 ->get();

    // do we have an entry and is it's status different?
    if ( ( $entry->num_rows() > 0 ) &&
         ( $entry->status !== $new_status ) )
    {
        // we have different entry status! do stuff here!
    }
}

```

The above code is completely untested, but that's the idea and *should* work just fine for your needs.
> 2 votes

---
Tags: module, hook, status
---


# Question
Title: Having trouble pulling titles from another channel into a sidebar
This is what I currently have, Ive only been using ee for about 1.5 wks so I'm pretty sure I can't do what I am below. The index and and practice\_dangers templates are in the same folder group but had to be in two different channels. Any help is appreciated.

```
{exp:channel:entries channel="aop" disable="pagination|categories|member_data" dynamic="no"}
<li><a href="{url_title_path='practice_area/index'}">{title}</a>
    <ul>
        {exp:channel:entries channel="practice_dangers" dynamic="no" disable="pagination|categories|member_data"}
        <li>
            <a href="{url_title_path='practice_area/practice_dangers'}">{title}</a>
        </li>
        {/exp:channel:entries}
    </ul>
</li>
{/exp:channel:entries}

```

# Answer
You can't have a exp:channel:entries tag inside itself, from your comment above it looks like you're using relationships. You should be using the appropriate tags to pull in the related entries. Replace relationship\_field with your actual relationship field\_name

```
{exp:channel:entries channel="aop" disable="pagination|categories|member_data" dynamic="no"}
<li>
    <a href="{url_title_path='practice_area/index'}">{title}</a>
    <ul>
        {relationship_field}
        <li>
            <a href="{relationship_field:url_title_path='practice_area/practice_dangers'}">
                {relationship_field:title}
            </a>
        </li>
        {/relationship_field}
    </ul>
</li>
{/exp:channel:entries}

```

You can read more about relationships here.
> 2 votes

---
Tags: relationships, title
---


# Question
Title: Solspace freeform "form expired" under EE 2.8
I'm having problems with a freeform form since upgrading to EE2.8. It keeps giving the following error on submit

This form has expired. Please refresh and try again.

Template caching is off.

Running freeform 4.1.3

```
{exp:freeform:form
    form_name="contact_form"
    return="contact_us/thank_you
}
<h3>Name:</h3><p><input type="text" name="name" /></p>
<h3>Email:</h3><p><input type="text" name="email" /></p>
<h3>Questions or Comments:</h3><p><textarea name="comment" rows="6" ></textarea></p>
<p><input type="submit" name="submit" value="Send It" class="button" /></p>
{/exp:freeform:form}

```

# Answer
> 5 votes
This issue involves the changed security module within EE. Solspace are working on the proper solution however I have also advised them on how to fix this issue (in a different module, facebook connect).

To help them and the community, try this:

1. Identify the action used to submit the freeform (refer to the exp\_actions) table.
2. Modify the action in exp\_actions, and set the csrf\_exempt column to 1 (true)

Try to submit your freeform, if it works then this is indeed the security model issue.

The above fix will work for you however it should be noted that this removes the freeform submission from the standard cross site scripting checks. You are relying on SolSpace's module to validate the submission.

As always, for production purposes I recommend you wait for SolSpace's official patch, but if the above method helps, please let SolSpace (and us) know!!

# Answer
> 4 votes
Freeform 4.1.3 is not compatible with EE 2.8. Solspace are working on an update.

Adjusting csft\_exempt to 1 in the exp\_actions table (Freeform - save\_form ) got rid of the error so it looks like this has been caused by the security model issue.

# Answer
> 3 votes
I received the form expired error message using Freeform 4.2.2 and EE 2.9.2. I added this to config.php:

```
$config['disable_csrf_protection'] = "y";

```

The form submitted, but I really didn't want to leave that setting there. I did a little more digging and found that I needed to add a CSRF Token to my form. So I added this hidden input within my freeform tags:

```
<input type="hidden" name="csrf_token" value="{csrf_token}">

```

I was then able to delete the config change above and the form submitted successfully.

---
Tags: solspace-freeform, ee2-upgrades
---


# Question
Title: Scheduled email campaign with expressionengine
I'd like to schedule the sending of emails, created with Firemail, to selected mailing lists.

I can see the postmaster module may do this, but the client has invested in Firemail and I have the mailing lists and campaigns set up, so I'd rather find another way to do this.

I've looked at Email Cron and ExpressionEngine cron, but I can't see a way to schedule emails to mailing lists.

Any help appreciated!

# Answer
Prob worth posting this question to the FireMail support forum on Devot-ee as I think that's where official support is provided for the module. :)

https://devot-ee.com/add-ons/support/firemail/viewforum/508
> 0 votes

---
Tags: email, mailinglist, cron, campaignmonitor
---


title: Can't Send Email

text:
# Question
Title: Can't Send Email
I'm running EE 2.6.1. I have setup a form using Freeform 3.5 but it wasn't sending notifications. I went through the Solspace troubleshooting guide and double-checked everything there. I found this thread and tried everything recommended there, to no avail. Here's where I am at this point...

I have already been using Mandrill to get around clients' server settings, so I did that from the get go on this site. However, when the Freeform form wouldn't send I tried a test from the Communicate tool. With SMTP set and using my Mandrill credentials, I get these errors:

**A PHP Error was encountered** Severity: Warning Message: fsockopen() \[function.fsockopen\]: unable to connect to smtp.mandrillapp.com:587 (Connection timed out) Filename: libraries/Email.php Line Number: 1884

**A PHP Error was encountered** Severity: Warning Message: Cannot modify header information - headers already sent by (output started at /home/closeit/public\_html/dashboard/codeigniter/system/core/Exceptions.php:170) Filename: core/Common.php Line Number: 408

**An Error Was Encountered** Unable to send email at this time. The following SMTP error was encountered: 110 Connection timed out Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

So I've tried switching the mail protocol to both PHP Mail and Sendmail. And although I receive the "Your email has been sent" notification, I never receive the email.

# Answer
> 1 votes
Some hosts don't support sending emails using SMTP, which is likely the reason you are getting that fsocket error. For this reason Mandrill and other API services recommend using their API which uses HTTP (vs SMTP).

Postmaster is a robust utility for using various email API services. You could use Postmaster to send all system emails with HTTP using Mandrill. Postmaster has a hooks API, so it could be used to send emails from Freeform directly, but that would require some PHP the first time around. So if the default system email override doesn't work, a deeper level of integration is just a few lines of code away.

While this doesn't exactly fix your problem exactly, it is an alternative solution to solve a bigger problem. https://objectivehtml.com/postmaster

# Answer
> 0 votes
No idea whether this is related to poster's case, but I had same problem on AWS EC2 server.

The solution was to enable 'default' security group for the server instance in AWS management console.

---
Tags: email, smtp
---


# Question
Title: Solspace Facebook Connect Register error when returns
i've an error when Facebook Register returns on my website. this is the error:

```
The following errors were encountered

This form has expired. Please refresh and try again.

```

The link in browser is like that

```
http://www.url.com/?ACT=54&hash=205d1b74bc165cddc18fcd32d5e22434

```

The request was sent by

```
https://www.url.com/site/register

```

Is there some issue with the https?

Thanks guys

# Answer
> 0 votes
Are you saying that you're using this on a secure page (HTTPS) and you're getting this error?

It's very important to know that Facebook has discontinued the Facebook Registration plugin and it will altogether stop working as of April 30, 2015.

https://developers.facebook.com/docs/plugins/registration/v1.0

> The Registration Plugin is deprecated and will be removed on April 30, 2015. You should not integrate this plugin into new apps. If you're using this plugin, you should replace it with Facebook Login before April 30, 2015

Solspace Facebook connect still currently uses the old v1.0 Facebook API and sites that do not update before April 30, 2015 will lose all Facebook functionality. That said, we are finishing up a new version of Facebook Connect that will be released any day now and will be fully compatible with current version of Facebook (v2.2 API). However, as mentioned earlier, the Registration plugin will not work, due to Facebook discontinuing it. :)

---
Tags: solspace, solspace-facebookconnect
---


title: Channel Videos - Dev Demon

text:
# Question
Title: Channel Videos - Dev Demon
Is it possible to remove "related videos" when the video has finished playing?

I know this is possible when using the embed directly, just wondered if i could replicate it with channel videos.

Thank You.

# Answer
There are a ton of features you can turn on and off in the module control panel.
> 0 votes

---
Tags: devdemon, channel-videos
---


title: Ajax Pagination

text:
# Question
Title: Ajax Pagination
I'm trying to use this script to AJAX load paginated entries in EE. There may be a far simpler way to do it though.

This script works, but replaces the current 10 entries with the next 10 entries, but instead I would like the next 10 entries to be appended to the list.

Also, clicking the Show More button should keep adding the next 10 '`<article>`'s and then the Show More button should disappear once there are no more to show.

```
<section id="articles">
    {exp:channel:entries channel="page" sort="asc" orderby="title" limit="10" paginate="bottom" dynamic="no"}
        <article>
            <h2>{title}</h2>
            {page_summary}
        </article>
        {paginate}
            {pagination_links}
                <ul class="pagination">
                    {next_page}
                        <li><a href="{pagination_url}">Show More</a></li>
                    {/next_page}
                </ul>
            {/pagination_links}
        {/paginate}
    {/exp:channel:entries}
</section>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
(function(a) {
    a.fn.pager = function(b) {
        var d = "#" + a(this).attr("id");
        var c = {
            link: ".pagination a",
            pull: d + " > *",
            loaderID: "loader",
            scrollTo: "body",
            fadeSpeed: 100,
            fadeOpacity: 0.5
        };
        var b = a.extend(c, b);
        a(b.link).live("click", function(g) {
            g.preventDefault();
            var f = a(this).attr("href");
            a(d, function() {
                a(d).fadeTo(b.fadeSpeed, b.fadeOpacity);
                a(d).after('<i id="' + b.loaderID + '" style="display: none;"></i>');
                a("#" + b.loaderID).fadeIn(b.fadeSpeed)
            }).load(f + " " + b.pull, function() {
                a(d).fadeTo(b.fadeSpeed, 1);
                a(window).scrollTop(a(b.scrollTo).position().top);
                a("#" + b.loaderID).fadeOut(b.fadeSpeed, function() {
                    a("#" + b.loaderID).remove()
                })
            })
        })
    }
})(jQuery);
</script>
<script>
$(document).ready(function() {
    $('#articles').pager();
});
</script>

```

I wondered if anyone might be able to point me in the right direction?

# Answer
Honestly, I wouldn't even mess with that plugin since that's what it's supposed to do. Just do a simple ajax call and append the data like this. Note the move of `#articles` to the main template, and `paginate_base` parameter in the embed template.

Main Template

```
<html>
    <head></head>
    <body>
        <section id="articles">
            {embed="main/embed"}
        </section>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                //set the click listener on pagination
                paginationClickHandler();
            });

            function paginationClickHandler() {
                $(".pagination li a").click(function(e){
                    e.preventDefault();

                    //link to the next set of articles
                    var href = $(this).attr("href");

                    //get new articles and pagination
                    $.get(href, {}, function(data){
                        //remove existing pagination
                        $(".pagination").remove();

                        //add new articles and pagination links
                        $("#articles").append(data);

                        //disable pagination click listener
                        $('.pagination li a').off('click');

                        //set new click listener with new pagination links
                        paginationClickHandler();
                    });
                });
            }
        </script>
    </body>
</html>

```

Main/Embed Template

```
{exp:channel:entries channel="page" sort="asc" orderby="title" limit="10" paginate="bottom" paginate_base="main/embed" dynamic="no"}
        <article>
            <h2>{title}</h2>
            {page_summary}
        </article>
        {paginate}
            {pagination_links}
                <ul class="pagination">
                    {next_page}
                        <li><a href="{pagination_url}">Show More</a></li>
                    {/next_page}
                </ul>
            {/pagination_links}
        {/paginate}
    {/exp:channel:entries}

```
> 3 votes

---
Tags: pagination, javascript, ajax
---


# Question
Title: Transcribe replace returning weird string
It's my first time with EE and I'm modifying the template of an existing blog. It's multilingual so it uses code like `{exp:transcribe:replace name='written_by'}` to display different texts, in this case, `Written by`.

On some pages, for example on an article single, this line of code returns `Written by` as it should.

However, on some pages, for example on the index, it returns `M10O93H7PQ09L8X1T49CHY01Z5J4TT91FGFR`...

Sample returned HTML code:

```
<a href="M00o93H7pQ09L8X1t49cHY01Z5j4TT91fGfrthe-real-url-appears-here">
    <img src="http://www.website.com/images/image.jpg" />
    <h3>Article title</h3>
</a>

<p>
    M10o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr <a href="/author/jdoe" class="author">Jhon Doe</a>
    M20o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr <span>Feb 25, 2015</span>
</p>

```

Template code:

```
{exp:channel:categories show_empty="yes" channel="my_channel" id="categorylist" category_group="11" style="linear"}

    <h1>{category_name}</h1>

    {exp:channel:entries channel="my_channel" category="{category_id}" limit="3" paginate="bottom"}
        <a href="{exp:transcribe:uri path='/article/'}{url_title}">
            {blog_post_main_image}
                <img src="{path}/{filename}.{extension}" />
            {/blog_post_main_image}
            <h3>{title}</h3>
        </a>

        <p>
            {exp:transcribe:replace name='written_by'} <a href="/author/{username}" class="author">{author}</a>
            {exp:transcribe:replace name='on_date'} <span>{entry_date format="%M %d, %Y"}</span>
        </p>
    {/exp:channel:entries}

{/exp:channel:categories}

```

Any idea why it does that? I tried to search a lot on Google and found nothing that could help me.

Thanks!

# Answer
> 1 votes
it's to do with parse order. something is mixed up.Can you try addin a parse="inward" to the exp:channel:entries or the exp:transcribe:replace tag?

---
Tags: templates, transcribe, multi-language, language, multilingual
---


# Question
Title: Expression Engine Entries Loop in Reverse
In Expression Engine, how would I go about retrieving the **latest** 3 entries from a channel and then loop through the result set in reverse? I tried something like this to no avail :

{exp:channel:entries channel="news\_events" limit="3" orderby="entry\_id|date" sort="desc|asc"}

# Answer
> 0 votes
I don't believe there's a way to do what you are asking with a single channel:entries.

One way or another you are going to have to make *two* passes through the data. Here are some ways:

* exp:query + channel:entries
* php + channel:entries
* channel:entries + embed + channel:entries
* channel:entries + re-sorting in the results on the client side with javascript

Here's the a working example of the `channel:entries + embed + channel:entries` method:

**template 1:** (this is the template you call in your browser)

```
{embed="my_template_group/my_embedded_template"
my_entry_ids='
{exp:channel:entries channel="news_events" limit="3" disable="categories|custom_fields|pagination|member_data" backspace="1"}{entry_id}|{/exp:channel:entries}
'}

```

Here we are passing three piped delimited entry\_ids as an embed variable to another template called `my_template_group/my_embedded_template`. Note well the single vs double quotes here.

**template 2** (referenced above as `my_template_group/my_embedded_template`)

```
<ul>
{exp:channel:entries channel="news_events" disable="categories|custom_fields|pagination|member_data" fixed_order="{embed:my_entry_ids}" sort="desc"}<li>{entry_id}:{title}</li>
{/exp:channel:entries}
</ul>

```

Here we have another `channel:entries` call. The key is that we are injecting our entry\_ids from the parent template in to the `fixed_order` parameter here and then flipping the sort to `desc`.

---
Tags: channel-entries
---


# Question
Title: redirect in add-on module redirecting me to admin control panel login form with # appended in URL
```
$this->EE->functions->redirect(BASE . AMP . 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=module_name_here' . '#tabsettings');

```

EE v2.9.2

I want to redirect the user after the person submits the form, then it fires off the redirect function.

When I append #tabsettings, it redirects me to the Admin CP login form. Here is the URL it directs me to:

```
http://project.dev/admin.php?/cp/login&return=Qz1hZGRvbnNfbW9kdWxlcyZhbXA7TT1zaG93X21vZHVsZV9jcCZhbXA7bW9kdWxlPWVlX3ZiX2ludGVncmF0aW9u#tabsettings

```

If I remove the #tabsettings, it will keep me within the module control panel, but I want it to load the settings view, which needs the #tabsettings to know which part of the view to load.

```
$this->EE->functions->redirect(BASE . AMP . 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=module_name_here');

```

# Answer
Brandon is correct - EE does not like a hash in a redirect URL.

Instead, try using flash data for this.

```
$this->EE->session->set_flashdata('selected-tab', 'settings');
$this->EE->functions->redirect(BASE . AMP . 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=module_name_here');

```

Then, in your module code:

```
if($tab = ee()->session->flashdata('selected-tab') && $tab == 'settings')
{
    // Add something here to your markup so that your JS will select the tab you want
}

```
> 1 votes

---
Tags: add-on, add-on-development, module, redirects
---


# Question
Title: I'm having trouble getting simple IF statements within a Playa tag to evaluate properly
**Channels and Fields Summary**:

* `Tours` channel - stores a list of all Vacations the site offers
* + `tour_specials` field - a Playa field, linked to the `Specials` channel indicating which Special Offers apply to this tour
* + `tour_show_specials_banner` field - a Switch to determine whether to show a special offer banner against this entry, if the `tour_specials` field has any entries
* `Specials` channel - list of Special Offers that can apply to multiple tours
* `Promotions` channel - stores lists of tours our partners want to promote. Though it sounds similar to Specials, it is distinct from a business perspective.
* + `promotion_tours` field - a Playa field that stores multiple `tours` channel entries, indicating which tours are linked to a promotion

**The Problem**:

* I have created a Promotions page that gets a Promotion, and lists all `tours` associated with the promotion from the `promotion_tours` Playa field
* The listing of tours in the Promotion also needs to check whether a tour has a Special Offer running, by looking at the `tour_specials` field in the `tours` entry to see if any `Specials` apply
* However, all the various code blocks below **WILL NOT** ever evaluate to true, in the event a tour listed has a Special associated with it

**The Code**:

Here's the master code block that outputs all Playa entries from the `promotion_tours` field (all tours associated with the promotion):

```
{promotion_tours dynamic_parameters="orderby|sort|limit" orderby="title" sort="asc" limit="10" disable="categories|category_fields|member_data" var_prefix="promotions" paginate="bottom"}

    <a href="{promotions:site_url}/{promotions:url_title}">
        <img src="{promotions:tour_gallery limit="1"}{promotions:tour_photo_file:thumbnail}{/promotions:tour_gallery}"/>

        <!-- PROBLEM STARTS HERE -->
        <!-- If we want to show a Special Offer banner... -->
        {if promotions:tour_show_specials_banner}

            <!-- Then check if there are any linked Specials -->
            {if {promotions:tour_specials:total_children} > 0}
                    <img class="special-offer-banner" src="{site_url}images/site/special-offer.png" alt="Special Offer" title="Special Offer" />
            {/if}

        {/if}
    </a>

{/promotion_tours}

```

I am using a `var_prefix` to allow my Playa entries to be paginated (see here for an explanation).

You can see where the problem starts is with `{if promotions:tour_show_specials_banner}`. That statement NEVER evaluates as TRUE, even when I know it should do. The following situations NEVER output anything:

```
{if promotions:tour_show_specials_banner}
{if tour_show_specials_banner}
{if {promotions:tour_show_specials_banner} == "y"}
{if promotions:tour_show_specials_banner == "y"}
{if {tour_show_specials_banner} == "y"}

```

I know some are syntactically incorrect but I'm getting to my wits end here...

HOWEVER, if I just output `{promotions:tour_show_specials_banner}` in my HTML, it outputs `y` in to the content! Which must evaluate as `TRUE`!

I'm seriously stumped. Any ideas?

# Answer
> 2 votes
There are some issues in EE 2.9 with conditionals on prefixed variables and variable modifiers which I don't totally grok. (See bug report here for some discussion.)

But the moral is, try this:

```
{if '{promotions:tour_show_specials_banner}' == 'y'}

```

---
Tags: playa, variable, ifelse
---


# Question
Title: Set custom field value inside channel form parameter
Is there a plugin that can do this?

```
{exp:channel:form custom_field="value" channel="my_channel"}{/exp:channel:form}

```

The reason I'm doing this is so that nobody can view what are the values I'm sending when creating an entry using channel form.

# Answer
> 0 votes
I'd suggest writing a simple extension using the channel\_form\_submit\_entry\_start extension hook, then adding your custom field data to `$_POST` there.

---
Tags: safecracker, channel
---


title: Add-On Issue in Upgrade of EE1 to EE2

text:
# Question
Title: Add-On Issue in Upgrade of EE1 to EE2
Upgraded EE 1.7.3 to EE 2.9.2, But on add-ons not updated. On frontend showing error like,

> Unable to load requested field type file: ft.ftype\_id\_8.php.
>
> Confirm the fieldtype file is located in the expressionengine/third\_party/ directory

How can i move all old add-ons like plugins,modules,extensions etc.

# Answer
> 3 votes
Directly from https://ellislab.com/expressionengine/user-guide/installation/upgrade\_from\_1.x.html :

```
IMPORTANT
Third-party add-ons from version 1.x will not work with ExpressionEngine 2.
Please contact each add-on’s author for a 2.x-compatible version before
upgrading, or your site may not function properly. The installer will
automatically disable all extensions as part of the upgrade process.

```

Big, and at the top of the page... you (whomever upgraded) definitely needed to vet which add-ons were in use and which ones had 2.x compatible versions before upgrading. I would highly recommend restoring backups to the original site and starting the process all over, but this time carefully examine all add-ons and find replacements for ones without compatible upgrades.

If there is no way to restore the site to previous 1.x functionality, all you can do is spend the time it will take figuring out what add-ons were in use and try to find suitable replacements quickly; the site will likely be broken until then.

---
Tags: ee1
---


# Question
Title: using Relationships field, want to display job listings per facility
I have a "Job Openings" channel with a relationship field. The field relates to the "Facility" channel. So when a user creates a new job opening entry, they relate the opening to the facility. Now in my template I want to display a list of facilities ONLY IF THEY HAVE JOB OPENINGS, then below the name of the facility, display all job openings.

I started with a channel entries tag for the facilities. How do I setup the conditional so it detects if there is a parent(job opening), display the facility title, then display all job openings for that facility? I only want the facility name to appear once, with all job openings for that facility below it.

The code I have below is not correct and displays the facility title for every job opening. I'm not sure how to setup the conditional correctly. Any ideas? Thanks for any help!

```
            {exp:channel:entries channel="facilities" disable="categories|member_data|category_fields" sort="asc" dynamic="no"}

            {parents field="job_facility"}
               {if parents:count >= "1"}
               <article class="job_summary">
                   <h1>{title}</h1>
                       <h2>Job Opening</h2>
                       <a href=""><h3>{parents:title}</h3></a>
               </article>
               {/if}
            {/parents}

            {/exp:channel:entries}

```

***This is what I want...***

* Facility 1
    + job opening
* Facility 2
    + job opening
    + job opening
* Facility 8
    + job opening

***And this is what I'm getting...***

* Facility 1
    + job opening
* Facility 2
    + job opening
* Facility 2
    + job opening
* Facility 8
    + job opening

# Answer
Expanding a bit on @CreateSean's comment to your question, you can use the `parents:count` and `parents:total_results` variables much like you'd use them in the Channel entries tag to generate "wrapper" markup.

```
{exp:channel:entries channel="facilities" disable="categories|member_data|category_fields" sort="asc" dynamic="no"}

  {parents}
      {if parents:count == "1"}
        <article class="job_summary">
          <h1>{title}</h1>
          <h2>Job Opening</h2>
      {/if}

             <a href=""><h3>{parents:title}</h3></a>

      {if parents:count == parents:total_results}
        </article>
      {/if}
  {/parents}

{/exp:channel:entries}

```
> 2 votes

---
Tags: relationships
---


title: Viewing Entry by non super admin group

text:
# Question
Title: Viewing Entry by non super admin group
My site is currently working well when everyone posting is under the Super Admin group, however I'm needing to make another group with the same privilege level as a Super Admin and begin assigning users to that group. Problem is that when users under this new group try to add pages through Structure, the page is white with nothing returned. I've run template debugging and have this returned :

http://jsfiddle.net/j4mcud87/

If posting as a Super Admin, everything works. Just when users under this new group post that nothing is coming through on the front end.

I'm using a generic tag to rule out anything blocking the content e.g.

```
{exp:channel:entries channel="site"}

```

Works for Super-Admin related content, just not the new group.

Has anyone experienced anything like this?

# Answer
This always boils down to proper User Group permissions. However, I'm guessing you've checked all those settings a billion times over. With that said, check to see if the entry status is changing to "Closed" when users from that new group publish changes.

If the status is in fact changing to "Closed", all you need to do to fix it is to make sure that all of your Channels have a "Status Group" assigned (you know, the one that contains the Open and Closed status). Admin \> Channels \> Edit Group Assignments.
> 1 votes

---
Tags: channel-entries, members
---


# Question
Title: Access shipping/billing using hook in Store
I'm trying to make an extension that allows the user to choose from a list of shipping and billing addresses that they have previously entered. I'm using the store\_order\_complete\_end hook listed here https://www.exp-resso.com/docs/extension\_hooks.html but I can't access the addresses in the $order object because the $order-\>attributes object is a protected attribute. Is there any other way to get the addresses for the order?

```
public function my_store_order_complete_end($order) {
    $vars = $order->attributes; // undefined as it's protected
}

```

# Answer
> 2 votes
All of the customer attributes are actually accessible as direct members of the `$order` object:

```
$order->billing_first_name
$order->billing_last_name
$order->billing_address1
$order->billing_city

```

Etc.

---
Tags: expresso-store
---


title: MSM Move entry from site A to Site B

text:
# Question
Title: MSM Move entry from site A to Site B
Within two sites under Multiple Site Manager, what would be the easiest way for an editor (ie:from the CP) to move or duplicate an entry from siteA to siteB ?

# Answer
Honestly: copying and pasting.

Since sites don't share fields, you'd have to setup a custom module which mapped fields between sites, then have it run a script to migrate the content for you. Then add third party fieldtypes into the mix and things could get even more complicated.
> 0 votes

---
Tags: multi-site-manager
---


# Question
Title: PHP Error when trying to assign a product channel in Cartthrob
Whenever I attempt to visit the Addons \> Modules \> Cartthrob \> Products page after installing CT, I receive the following PHP errors: (http://cl.ly/image/2H0t162L2A2c).

```
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: channel_dd
Filename: views/product_channels.php
Line Number: 206

```

And

```
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: helpers/form_helper.php
Line Number: 324

```

This only happens when the default product channel doesn't exist. After creating the default channel I'm able to assign a new, custom product channel and delete the default.

I'm running EE 2.8.1 and CT 2.5.

Is this a known bug in Cartthrob, and is there a way to assign a product channel without first creating the default products channel?

# Answer
So I know this question was posted a while back, but I arrived at it when I had the same problem and thought I would share my solution.

In exp\_cartthrob\_settings table in the database, find the rows with the key 'product\_channels' and 'product\_channel\_fields', duplicate these rows and change the site\_id and key values to match the site and channel field IDs.

This was useful for me when I was setting up my MSM second site. Also, I had created the new Products channel first in the MSM site so that I could get the channel field IDs.
> 0 votes

---
Tags: cartthrob, php-errors
---


# Question
Title: Programatically add entryID to another entries playa field
I'm looking to set up a situation where a user can visit an entry and create a related entry. The original entry will be the parent, the new entry the child.

The issue is the 'related' entry needs to add itself to the parents entry (playa list), so I'll likely need to create a module or something.

The part that has me flummoxed is simply adding the properly formatted inputs to the Channel Data via mySQL etc does not update the playa field & doesn't work.

Yet, if I open up a channel form (parent entry) and add some hidden inputs – when saved, it correctly updates its playa content. So it's only when saving (Channel form) that both the Channel Data and Playa content gets updated.

Imagine this:

* User visits entryA & clicks 'create related entry'
* url = /create/{entry\_id} \<- Parent entry ID
* Saves channel form (No playa data)
* After it's saved, fire off some 'magic' so it triggers the update to the Parent Entries (entryA) channel data field and also fires an update to the exp\_playa table as well - I almost need like an invisible channel form to fire.

If you're still reading: I need some guidance on how to achieve something resembling this and everyone gets a cookie :)

# Answer
Flipping your example around, you can make the relationship field on the child entry. Then add the parent entry to that newly created child by grabbing it from the segment and using hidden playa input(s).
> 0 votes

---
Tags: playa, relationships, related-entries
---


# Question
Title: Channel Entries - Structure / Categories / URLs
I've spent so many hours trying to work this issue out. Aggravating. I have a channel "Baler", this channel has various categories and these categories have sub categories. eg:

Balers \- Parent Category \- Sub Category \- Sub Category

I would like to display the content for each page based on the last segment of the url. In order to do this do I need to create a structure page for each category(even though when I create a category it is assigned a URL)

Right now my code looks like this:

---

```
{if freebie_2 != "" && freebie_3 == ""}

    {exp:channel:categories
        channel="{freebie_1}"
        style="linear"
        category="{last_segment_category_id}"}

        {if {parent_id} != 0}
            <div class="Product1">
                <a href="{category_url_title}"><h2>{category_name}</h2>
                    <img src="{category_image}" alt="{category_name}" title="{category_name}" /></a>
            </div>
        {/if}

    {/exp:channel:categories}

{/if}

{if freebie_2 != "" && freebie_3 != ""}

    {exp:channel:entries
        channel="{freebie_1}"
        category="{last_segment_category_id}"
        paginate="bottom" limit="20" dynamic="no"}

        <div class="Product1">
            <a href="/{freebie_1}{freebie_2}/{page_uri}"><h2>{title}</h2>
                <img src="{baler_images}" alt="{title}" title="{title}" /></a>
        </div>

    {/exp:channel:entries}

{/if}

```

The main issue is, that if I have to add in 500 categories and sub categories, do I need to create all of these as structure pages also? Any help or guidance would be really appreciated.

# Answer
The point of using freebie is that you shouldn't need to add them as actual pages.
> -1 votes

---
Tags: channel-entries, categories, structure, url, child-categories
---


# Question
Title: General SEO page question - dynamic vs static?
What's better from a SEO perspective?

I normally generate a lot of my page dynamically using only one template and segments. But for SEO purposes is it better (?) to create a static template for each distinct page type?

# Answer
> 2 votes
Those things do not matter. Some important SEO stuff:

Are your page urls consistent and do they always load the same content? Will /segment1/segment2/segment3 always show the same main content (things like sidebar ads always change and isn't penalized)

Do the segment paths make sense? This is good:

/blog/jchrono-battle/why-i-use-expression-engine

This is bad:

/templates/blogtemplate\_1/jchrono-battle/12345

Does your HTML structure follow best practices for HTML5, using modern tags to create better crawlable structures

```
<header>
    <nav>
        <ul><li>Nav here!</li></ul>
    </nav>
</header>
<article>
    <h1>Article Title</h1>
    <section>Article section</section>
    <section>Article section</section>
    <aside>Side note!</aside>
</article>

<footer>
    Footer here!
</footer>

```

instead of being blogged down by

```
<div> <div> <div> .... </div> </div> </div>

```

The bottom line is that *how* you generate your HTML output doesn't matter, it's all the best practices for SEO you put on top of those URL schemes and generated pages.

**Edit** This post isn't meant to be all encompassing, but AllInOne mentioned one of the more important aspects of SEO optimization (thanks!). Page time to load and render is weighted pretty importantly, so make sure you are keeping your styles minified and combined, and your JS minified, combined, and (where appropriate) mangled. Also don't forget to use appropriate image sizes and formats. Don't load a 2000x2000px PNG file with a 500x500px jpeg works in place (extreme example).

http://lmgtfy.com/?q=SEO+Best+Practices

There's a million resources for what is *best* here and it can be conflicting, so I'd suggest looking towards articles by the crawlers (google, bing, yahoo) on what matters the most.

Some good starters:

http://www.bing.com/toolbox/seo-analyzer

http://static.googleusercontent.com/media/www.google.com/en/us/webmasters/docs/search-engine-optimization-starter-guide.pdf

https://support.google.com/webmasters/answer/70897

---
Tags: seo
---


title: Channel Form File Upload Question

text:
# Question
Title: Channel Form File Upload Question
I don't think I quite understand from the EE documentation how to upload a file using a Channel Form (previously SafeCracker).

I would like to upload my sermon audio files into the sermons upload path (http://example.com/sermon-files/). The file channel field I have is called {sermon\_file}.

Here is the code from the documentation:

```
<div class="form-group">
    <input type="file" name="my_field_name" />
    <input type="hidden" name="my_field_name_directory" value="1" />
    <input type="hidden" name="my_field_name_hidden_file" value="{my_field_name}{file_name}{/my_field_name}" />
</div><!--/.form-group-->

```

This assumes that the {exp:channel:form channel="sermons"} tag is before all this code and contains a submit button.

My question is, what the heck do I put in these "my\_field\_name" placeholders?

Appreciate any help you can offer. Thank you much!

# Answer
They should be the field name you gave your file field which you said was `{sermon_file}`. Or you could always just replace all that with `{field:sermon_file}`

```
<div class="form-group">
    <input type="file" name="sermon_file" />
    <input type="hidden" name="sermon_file_directory" value="1" />
    <input type="hidden" name="sermon_file_hidden_file" value="{sermon_file}{file_name}{/sermon_file}" />
</div><!--/.form-group-->

```
> 1 votes

---
Tags: safecracker, channel, file-uploads, safecracker-file
---


# Question
Title: Any reason not to sync templates to database?
I have a site with a lot of templates. Some are edited right from the control panel, but some are edited from ftp by "save as file". I like to keep a bit of revision history, so that if I accidentally delete something in a template, I can easily restore it.

Often I'll work on a template remotely, and then when I'm done what I'm working on, go find it in the CP, and update it, so that it syncs with the database, and also so that it saves a revision.

Just recently I came across Design \> Templates \> Synchronize templates. That page shows that some of my templates are up-to-date, but some are not. Is there any reason that it would be harmful to just select "sync all"? I can't think of why there would be, but then why doesn't it just sync automatically when you save the template remotely.

Also, I'm assuming that syncing a template from that page doesn't add it to the revision history, correct?

# Answer
> 1 votes
It shouldn't be harmful to perform the sync. The worst thing that could happen is that ExpressionEngine doesn't recognize which of the two versions are more recent and syncs them the wrong direction. This might have happened to me many years a go very early on in version 2. I would however argue that it can be harmful NOT to perform an occasional sync. Reason being is that if the actual files are inaccessible, ExpressionEngine falls back to the version stored in the database. As far as revision history goes, syncing doesn't update it (as far as I can remember). The proper way is to do file based development and use git to version control your changes. But I realize budgets sometimes lead to cowboy development :)

---
Tags: templates, sync
---


# Question
Title: lang parameter in Low Events with Publisher
What does Low Events expect as a value for the `lang` parameter?

I've been trying to pass Publisher's `{publisher:current_language_id}`, `{publisher:current_language_code}` and `{publisher:current_language_prefix}`, but the dates will not get translated. I even tried hardcoding `lang="2"`, but it won't get the english translation.

```
{exp:low_events:entries
channel="channel" limit="3"
lang="{publisher:current_language_id}"
show_passed="yes"
show_upcoming="yes" unit="custom"
date_from="-1 year"
date_to="+1 year"
}

```

# Answer
> 0 votes
I misread Low events documentation. The lang parameter is to be used in the variable and not in the low events tag.

`{myfield:start_date lang="{publisher:current_language_code}"}` works perfectly.

---
Tags: date, low, low-events, localization, publisher
---


# Question
Title: upgraded WYGWAM 3.3.3 - config icons not right
When I go into the toolbar config this icon http://d.pr/i/3UIj is used for inserting an image.

No console errors. When I look at the actual publish page, everything is as expected.

Tried clearing the cache to no avail.

Anyone seen similar?

# Answer
> 1 votes
I had the same problem after updating Wygwam from 3.2.2 to 3.3.3 on EE 2.7.3. I found that it's a browser cache issue. After clearing out the cache, the icons were back.

---
Tags: wygwam, wysiwyg, config
---


title: Altering CartThrob CSV export settings

text:
# Question
Title: Altering CartThrob CSV export settings
A client uses the purchased\_item\_notes field for customer order notes, and would like to export those in the order reports. This purchased\_item\_notes content displays on the CMS view of the generated order report, but when you export to CSV, the file trims away the data from that field.

Is it possible to alter the CSV export settings to include all the data in the generated report?

Using CartThrob Order Manager 2.5 and EE 2.8.1.

# Answer
Do can do a custom report and have it format it exactly then way you want. I do this and use the http\_header add-on to generate an cvs that downloads at the click of a button and gets imported into Xero. The other advantage is that your client does not have to select all those report options each time they want to generate a report.
> 0 votes

---
Tags: cartthrob, csv
---


# Question
Title: Displaying Structure sub-nav on child pages
The documentation shows how to put a sub-nav on a parent page with children, but how do I display the same sub-nav on the child pages? http://buildwithstructure.com/documentation/conditionally\_display\_sub\_navigation\_or\_html/

# Answer
> 1 votes
You can use additional or statements to check if you're past or at a certain segment if you want to show it as you go down. Otherwise, sometimes it's easier to use different templates for pages you do or do not want to show it.

# Answer
> 1 votes
I display the menu in an embed with the parent template passing the relevant Entry IDs to display. So using this conditional:

```
{if "{structure:child_ids}"}
    {structure:child_ids}
{if:else}
    {exp:structure:entries parent_id="{structure:parent:entry_id}" backspace="1"}
        {entry_id}|
    {/exp:structure:entries}
{/if}

```

If child page exist, render out the entry IDs of the children, otherwise when you're in one of the child pages, get the parents children.

Putting it together:

```
{embed="block-embeds/.hub-nav" menu_entries="{if "{structure:child_ids}"}{structure:child_ids}{if:else}{exp:structure:entries parent_id="{structure:parent:entry_id}" backspace="1"}{entry_id}|{/exp:structure:entries}{/if}"}

```

Then on the child template I have this channel entries call:

```
{exp:channel:entries
    channel="content"
    dynamic="no"
    fixed_order="{embed:menu_entries}"
    disable="member_data|pagination"}

```

---
Tags: structure
---


# Question
Title: Using Channel entries with orderby="random" without repeating entry ids
I'm using EE for a basic assessment platform and the questions (entries) are presented to the user need to be in a random order from a fixed list so that the order of questions changes per user.

```
{exp:channel:entries entry_id="{embed:ids}" orderby="random" dynamic="no" limit="1"}

```

This simplified format refreshes the channel:entries loop and results in repeated questions.

How can I ensure that the entry\_ids sent through the embed aren't repeated as the user paginates through the entries 1 by 1?

Thanks!

# Answer
There's two issues - the generation of the original ids in the parent and your example not using pagination. You've not given the code for how the entry IDs are generated in the parent, but will it always be different upon each visit for the same user or it generates the same entry IDs?

Assuming that the parent is generating the same Entry ID list for that user consistently, it sounds like you're just repeating the page each time (based on the code you provided), therefore it's randomising each time. Use Pagintion instead:

```
{exp:channel:entries entry_id="{embed:ids}" orderby="random" dynamic="no" limit="1" paginate="bottom"}

  Question stuff here.

  {paginate}
    <p>Question {current_page} of {total_pages}</p>
    {if next_page}
        <a href="{auto_path}">Next Page</a>
    {if:else}
        <a href="completed URL here">Finished</a>
    {/if}
  {/paginate}
{/exp:channel:entries}

```

Pagination will build the random order for all results found (the unchanging entry ID list), then only display one question on screen. When using the pagination links, it will refer to the original order created, not regenerate each time.

If the parent that creates the {embed:ids} is generating them differently on each page load, try saving the entry ID list to a session variable instead, and if it exists, use it rather than generate a new list.

```
{if '{exp:session_variables:get name="question-order"}'}
    Don't generate
    {embed=..... ids="{exp:session_variables:get name="question-order"}"}
{if:else}
    Generate
    {exp:session_variables:set name="question-order" value="generated entry IDs"}
    {embed=..... ids="generated entry IDs"}
{/if}

```

Then once the assessment is complete, clear the variables:

```
{exp:session_variables:delete name="question-order"}

```
> 1 votes

---
Tags: entries, orderby, random
---


title: url_title_path not linking correctly

text:
# Question
Title: url_title_path not linking correctly
I'm going nuts with this. I'm new to EE and Channel Images and just cant see why this is not working.

Gallery page with a bunch of thumbs:

```
<div id="thumbContainer">
  {exp:channel:entries channel="some_images" limit="20"}
    {exp:channel_images:images entry_id="{entry_id}"}
      <div class="galleryGrid">
        <a class="gallery" href="{url_title_path='portfolio/myview'}"><img src="{image:url:thumb}" /></a>
      </div>
    {/exp:channel_images:images}
  {/exp:channel:entries}
</div>

```

The thumbs link to the main image on another page:

```
{exp:channel:entries channel="some_images" limit="1"}
  <section class="wrapper">
    <div class="backToPortfolio"><a href="{path='portfolio/gallery'}"><span class="fa fa-angle-double-left"></span>Back To Portfolio</a></div>
    <div class="stage">

      {exp:channel_images:images entry_id="{entry_id}" limit="1"}
        <img class="mainImage" src="{image:url}" alt="{image:title}" />
      </div>
        <article class="description">
          <h2>{image:title}</h2>
          <h6>{image:field:1}</h6>
          <p>{image:description}</p>
      {/exp:channel_images:images}

      <div class="imageNavLeft">
        <a href="{path='portfolio/myview'}"><span class="fa fa-chevron-circle-left"></span></a>
      </div>

      <div class="imageNavRight">
        <a href="{path='portfolio/myview'}"><span class="fa fa-chevron-circle-right"></span></a>
      </div>

    </article>
  </section>
{/exp:channel:entries}

```

No matter which thumb I click on it only ever displays the first gallery image. The 'myview' page displays ok but with the wrong image. Its like url\_title\_path is not working. Seems like I'm missing something very basic but too tired and not enough knowledge to see it! Frustratingly I had it working perfectly until I involved Channel Images and I broke it somehow.

Any help gratefully appreciated.

# Answer
> 0 votes
I've never been a fan of the EE path and prefer to use more traditional linking, like this:

PS. Never used channel images so using `{file:id}` as a segment marker as well as the curl\_title of the channel entry itself.

```
<div id="thumbContainer">
  {exp:channel:entries channel="some_images" limit="20"}
    {exp:channel_images:images entry_id="{entry_id}"}
      <div class="galleryGrid">
        <a class="gallery" href="/portfolio/myview/{url_title}/{file:id}"><img src="{image:url:thumb}" /></a>
      </div>
    {/exp:channel_images:images}
  {/exp:channel:entries}
</div>

{exp:channel:entries channel="some_images" limit="1" url_title="{segment_3}"}
  <section class="wrapper">
    <div class="backToPortfolio"><a href="{path='portfolio/gallery'}"><span class="fa fa-angle-double-left"></span>Back To Portfolio</a></div>
    <div class="stage">
      //
      //Added file_id="{segment_4}" to make sure this single view page targets correct image
      //
      {exp:channel_images:images entry_id="{entry_id}" file_id="{segment_4}" limit="1"}
        <img class="mainImage" src="{image:url}" alt="{image:title}" />
      </div>
        <article class="description">
          <h2>{image:title}</h2>
          <h6>{image:field:1}</h6>
          <p>{image:description}</p>
      {/exp:channel_images:images}

      <div class="imageNavLeft">
        <a href="/portfolio/myview/{url_title}/{file:id}"><span class="fa fa-chevron-circle-left"></span></a>
      </div>

      <div class="imageNavRight">
        <a href="/portfolio/myview/{url_title}/{file:id}"><span class="fa fa-chevron-circle-right"></span></a>
      </div>

    </article>
  </section>
{/exp:channel:entries}

```

Basically without seeing your destination page, I'm including the `file:id` \+ the EE entries `{url_title}` in the link so on the destination page you can target `{segment_3}` & `{segment_4}` to implicitly call the EE entry and the corresponding CI image.

`htttp://ansite.com/portfolio/my_entries_url_title/channel_images_entry_id`

Disclaimer: Never used channel images and am unsure of how an uploaded images are output individually. I always thought Channel images was specifically for displaying multiple images on one page.

---
Tags: channel-images
---


# Question
Title: Categories not filtering with Low Seg2Cat
I am having some problem with the Low Seg2Cat extension. I am trying to load all entries for a particular category using the third URI segment. For instance: '/specials/category/europe'. This is the current basic markup:

```
{exp:channel:entries channel="specials" orderby="date" category_group="8" category=segment_3_category_id}
<p>{entry_date format='%j%S %M %Y'}</p>
<p>{specials_excerpt}</p>
{/exp:channel:entries}

```

However, all this outputs at the moment is *any* item that has been categorised. For instance, items categorised as 'Europe' or as 'USA'. Uncategorised items do not appear. Moreover, *any value* entered into segment 3 returns this same list.

I am currently using (and have just upgraded to) EE 2.9.2 before developing this page. Low Seg2Cat is in its latest version, 2.8.1.

Any help would be appreciated!

# Answer
Your code should look like this (note the end of the opening `channel:entries` tag - you were missing a combination of quotes and curly braces):

```
{exp:channel:entries channel="specials" orderby="date" category="{segment_3_category_id}"}
    <p>{entry_date format='%j%S %M %Y'}</p>
    <p>{specials_excerpt}</p>
{/exp:channel:entries}

```

I've also omitted the `category_group` parameter, since it is overridden by the `category` parameter.

Be sure that your selected category group is chosen in the Low Seg2Cat extension settings.

I should also add that if you set your category URL indicator to "category", then you wouldn't need Low Seg2Cat in this specific case (and you could remove the `category` parameter entirely) - the URL you showed would automatically load all entries in the "europe" catgeory.

> EE 2.9.2 has phased out the use of nesting multiple curly braces

This is not true. You only omit the braces inside of *conditionals* (and even then, sometimes you may still need to use quoted parsed variables there). Everywhere else, variables need braces around them in order to be parsed and used.
> 1 votes

# Answer
You need to surround `segment_3_category_id` in parethesis and {}

```
category="{segment_3_category_id}"

```
> 1 votes

---
Tags: channel-entries, categories, low-seg2cat, category-group
---


title: Expresso Store with Grid type field

text:
# Question
Title: Expresso Store with Grid type field
I've been asked to set up an event booking system on an installation that already has Expresso Store. I can set up each event as a product item, and let visitors use the quantity field to specify booking numbers. But I also need to capture information on each person booked. I can include a text field modifier, but I would need a flexible number of fields for an unknown booking number. Is there a way to turn the text modifier field into a grid type field?

# Answer
> 2 votes
There is nothing out of the box that would allow you to do this. You would either need to create an extension, use JavaScript or change your workflow around a bit.

In the past I have usually seen it done where you enter a single users information in a modal window then click an add another button which will add that item to the cart and refresh the modal window to add the next person information. This would be repeated until you added all of the people and you could click submit.

Alternatively I have seen this done where a user will select the product and quantity which will load a new page using the product form tag and repeating the product based upon the quantity the user entered. Then the user would fill out the fields as needed and submit to add the item to the cart.

Both of these methods work because Store will see the same item with different text modifiers as different items in the cart.

---
Tags: expresso-store
---


# Question
Title: Ouput modifier tags (price) as radio buttons
I'm having a hard time understanding the documentation and outputting price modifiers as radio buttons.

Im trying to build a make shift gift card thing since store doesn't support that yet.

I want radio buttons for the fixed amounts, and then a custom text field for any custom amount. I need it to be output as radio buttons and a text field. As long as it affects the price in the cart, the rest will be fine.

Been trying with the examples fmor the docs, but even the select list is giving me trouble.

Any help is much appreciated, thanks!

# Answer
> 2 votes
First, you need to make sure "Enable Dynamic Prices?" is set to Yes under Admin \> Channel Administration \> Channel Fields \> Products \> Product Details.

You can then submit a `price` field as part of your add to cart form:

```
{exp:store:product entry_id="123"}

    <label><input type="radio" name="price" value="10" /> $10</label>
    <label><input type="radio" name="price" value="20" /> $20</label>
    <label><input type="radio" name="price" value="50" /> $50</label>

{/exp:store:product}

```

# Answer
> 0 votes
Just posting here since others may wonder what I just had a problem with and found this topic.

Make sure if you're wanting to just use "{price}" for one of the options, appened it with \_val or it'll just show up as $0. It's easy to miss in the official docs.

* "{price}" = "$123.00" (won't work due to automatic formatting)
* "{price\_val}" ="123.00"

---
Tags: expresso-store
---


# Question
Title: 404 not working; bad URLs show only blank page
My website is displaying a blank page when incorrect/absent URLs are used. But I would like it to show a 404 page such as this template I've created.

I have tried to set my global template preferences, as recommended here, but each time I hit save it reverts back to "none" for the 404 template preference.

I have attempted to use codes such as: {if no\_results} {redirect="404"} {/if}

and

{if no\_results OR segment\_2!=""} {redirect="404"} {/if}

and have even changed "404" to a full URL ... All to no avail.

Oh, and I also created a global variable, {404} using {if no\_results} {redirect="404"} {/if} as the content. (Grasping at all straws here!)

My EE and other coding knowledge is very basic, but I can generally understand basic instructions. I've tried searching online for the answer and am coming up blank.

Any advice?

# Answer
These settings might be coded up in config.php which would override attempts to change the global template preferences set in the CP. You shouldn't need that global variable, sounds like trouble to me.
> 0 votes

# Answer
Christy is correct saying that your config.php settings are overriding the control panel settings.

Based on the settings you listed, you should be able to remove or comment out the line

```
$config['site_404'] = "404/index";

```

Then continue following the EllisLab guide to set the correct 404 template from within the control panel.
> 0 votes

---
Tags: redirects, 404, no-results
---


title: Syntax for checkboxes in extension

text:
# Question
Title: Syntax for checkboxes in extension
I’m creating a custom ExpressionEngine extension and I need to add a checkbox. I’m struggling to find the options I need to use for the channel fields API.

Currently I have:

```
array(
    'field_name' => 'business_for_sale',
    'field_label' => 'Business For Sale?',
    'field_type' => 'checkboxes',
    'field_order' => 25,
    'field_instructions' => 'Is there a business for sale with the commerical property?',
    'field_required' => 'n',
    'field_search' => 'y',
    'field_is_hidden' => 'n',
    'field_list_items' => "Yes",
)

```

I just want either a single checkbox that will act as a boolean (checked is yes, un-checked is no). Alternatively, I would settle for two radios buttons—one representing Yes and one representing No that the administrator could choose.

# Answer
> 0 votes
Native EE checkbox fields simply store the options as plain text - to my knowledge there is no way to make one a *true* boolean. But what you have should work. The box being left unchecked will result in a NULL value for that field.

So all these should work.

```
{if business_for_sale == 'Yes'}
{if business_for_sale}
{if business_for_sale == ''}

```

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


# Question
Title: Strip line breaks, quotes, HTML out of SQL query result for CKEditor field contents (for CSV output)
I have a very simple "PHP allowed" EE template that queries the EE db and generates CSV reports from it. I need to add to one of these reports the contents of one particular channel field, which happens to be a CKEditor field. The double quotes and line breaks within the contents of this field in some rows are wreaking havoc with my CSV output, and other HTML doesn't actually break the CSV but is useless at best in the context of readable CSV output.

So what's the most straightforward way to strip out line breaks and doublequotes, and maybe also all HTML, without having to install any new add-ons, which to my eternal chagrin I cannot do on this site?

My full template code is below... you obviously won't be able to run it because my channel field definitions are unique, but it shows you the simplicity of what I am doing, so I'm hoping for a likewise simple solution to my HTML stripping issue.

```
<?php
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=report.csv');
?>"Title","URL title","First name","Last name","Notes"
<?

    {exp:query sql="SELECT title, url_title, field_id_128 AS 'FirstName', field_id_129 AS 'LastName', field_id_132 AS 'Notes' FROM (exp2_channel_data cd JOIN exp2_channel_titles ct ON ct.entry_id = cd.entry_id) WHERE cd.site_id = 3 and cd.channel_id = 19 GROUP BY cd.entry_id ORDER BY field_id_129"}
        ?>"{title}","{url_title}","{FirstName}","{LastName}","{Notes}"<?
        print "\n";
    {/exp:query}
?>

```

# Answer
> 1 votes
I see that you can't use add-ons. I also realized that my previous answer would not work because of parse order issues between EE tags and PHP. Here is an updated, purely PHP answer for you. I've tested it on a template with PHP turned on (doesn't matter if it's input or output).

Credit definitely goes to this stack answer: https://stackoverflow.com/questions/3933668/convert-array-into-csv

I simply modified it to fit your needs. You may also have to modify it for whatever your final CSV format requirements are. I wanted to give you an answer using the fputcsv() PHP function, but it's broken and will only enclose values if certain conditions are met, and you can't force it to enclose every field.

```
<?php

// Set headers
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=report.csv');

/**
  * Formats a line (passed as a fields  array) as CSV and returns the CSV as a string.
  * Adapted from http://us3.php.net/manual/en/function.fputcsv.php#87120
  */
function arrayToCsv( array &$fields, $delimiter = ';', $enclosure = '"', $encloseAll = false, $nullToMysqlNull = false ) {
    $delimiter_esc = preg_quote($delimiter, '/');
    $enclosure_esc = preg_quote($enclosure, '/');

    $output = array();
    foreach ( $fields as $field ) {
        if ($field === null && $nullToMysqlNull) {
            $output[] = 'NULL';
            continue;
        }

        // Enclose fields containing $delimiter, $enclosure or whitespace
        // Also strip html tags
        if ( $encloseAll || preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field ) ) {
            $output[] = $enclosure . strip_tags(str_replace($enclosure, $enclosure . $enclosure, $field)) . $enclosure;
        }
        else {
            $output[] = $field;
        }
    }

    // Return with new line ending
    return implode( $delimiter, $output ) . "\r\n";
}

// Use the database class to get the query
$f = ee()->db   ->select("title, url_title")
                ->from("exp_channel_titles")
                ->get()->result_array();

// Open output to browser
$fp = fopen('php://output', 'w'); // this file actual writes to php output

// Headers
$out = '"Title","Url Title"' . "\r\n";

// Autobots, write, transform, and roll out
foreach($f as $row)
{
    $out .= arrayToCsv($row, ',', '"', TRUE);
}

fwrite($fp, $out);
fclose($fp);

?>

```

# Answer
> 1 votes
Would a plugin like Streeng work out for you? https://github.com/caddis/streeng

It allows you to find/replace text. It can encode/decode HTML character codes, selectively strip HTML, etc.

As jchrono-battle said, I'd be surprised if there wasn't a CSV exporter already available.

---
Tags: html, csv, strip-html
---


# Question
Title: Error: Unable to locate the model you have specified: discount_model on Cartthrob
I'm running EE v2.9.2 and Cartthrob 2.61

The store processes the order and send the notification, on return, I receive the following error:

**"Unable to locate the model you have specified: discount\_model"**

Any help & insight is appreciated. Thanks.

# Answer
> 0 votes
For the meantime, i commented out the following lines at third\_party/cartthrob/drivers/core/Cartthrob\_core\_ee.php and it did the trick. We don't use discounts anyway :)

```
//formerly process_coupon_codes
public function process_discounts()
{
/*
    $this->EE->load->model('discount_model');

    $this->EE->load->model('coupon_code_model');

    $this->EE->discount_model->process_discounts();

    $this->EE->coupon_code_model->process_coupon_codes();
*/

```

Hoping someong can provide a better solution, but this will do for now.

# Answer
> 0 votes
I've just encountered this, but it's "COUPON\_CODE\_MODEL" that can't be found in my install. I'm on the same versions of EE & CT.

This is happening when I try to check out with Offline Payments, when I have set "When order is taken, set processing status to:" to "Complete", rather than "Processing". When "Processing" it submits fine; when "Complete", I get the error message.

---
Tags: cartthrob
---


# Question
Title: Totaling up and averaging numeric Matrix/Grib fields
I'm building a review channel and would like to know how to go about developing this. Say for instance I'm reviewing an album and have the ratings breakdown into different categories with ratings like so:

* Album art ------- 9
* Lyrics ------------7
* Instrumentals --- 9
* Vocal range ---- 5

**Album score ------- 7.5**

The ratings will be for the author to decide, not the public. This is what I'm envisioning in the EE backend:

```
[+] Matrix/Grid row: "[category dropdown column] and [score dropdown column]"

```

I'm wondering how I would go about totaling up and averaging out the score to be displayed to the public?

# Answer
Matrix actually comes with this functionality, if you look at their docs, there is a average function.

```
{exp:channel:entries channel="YOUR_CHANNEL"}
    {YOUR_MATRIX_FIELD:average col="SCORE_COL"}
{/exp:channel:entries}

```

Grid also has this function listed in their docs

```
{exp:channel:entries channel="YOUR_CHANNEL"}
    {YOUR_GRID_FIELD:average column="SCORE_COL"}
{/exp:channel:entries}

```
> 2 votes

---
Tags: matrix, grid
---


# Question
Title: Solspace User: Registration- force Username to be concatenation of 2 custom member fields
Upon registration using Solspace User, I would like to force the submitted username to be equal to first\_name|last\_name, similar to how the Screen Name is created. Is this possible?

# Answer
> 0 votes
Unfortunately this isn't possible. I recommend submitting this as a Feature Request under the specific add-on category. It'll also give other users the option to vote up the feature request, and help us prioritize features to add in upcoming versions of this add-on. http://support.solspace.com/support/discussions

# Answer
> 0 votes
I do this with a bit of javascript.

```
<script>
$().ready(function() {
$("#username").focus(function() {
var firstname = $("#first_name").val();
var lastname = $("#last_name").val();
var letter = firstname.charAt(0).toLowerCase();
var lname = lastname.toLowerCase().replace(/\s/g, "");
if(letter && lastname && !this.value) {
this.value = letter + lname;
}
});
</script>

```

---
Tags: solspace-user, registration
---


title: SolSpace User strips out line breaks?

text:
# Question
Title: SolSpace User strips out line breaks?
I'm trying to get SolSpace User to output a cvs formatted file, but I can't get it to leave in the line breaks, so it only produces one row with all the data in it.

Can anyone confirm that User strips out the line breaks, and is there a way to get it not to?

thanks!

my code:

```
'ID,Status,Last name,First name,Email,Last Payment,Join Date
{exp:user:users orderby="total_entries" sort="desc" dynamic_parameters="no" limit="500" }{member_id}{if group_id == 10}Member Admin,{/if}{last_name},{first_name},{email},{payment},{join_date format="%m/%d/%y"}
{/exp:user:users}

```

# Answer
> 0 votes
If this is outputted on a webpage, you need to add `<br />` at the end of the line to create a visual linebreak in the browser.

If looking at the output *source*, however, your code indeed outputs in one line. After some testing, it seems to be because of the `{if group_id == 10}Member Admin,{/if}` part in your code: remove that conditional, and newlines reappear.

This seems to be an issue with EE's parsing of conditionals, because the same phenomenon was observed with native EE tags. Eg:

```
{exp:channel:entries}{entry_id}
{/exp:channel:entries}

```

vs

```
{exp:channel:entries}{entry_id}{if entry_id == 123}test{/if}
{/exp:channel:entries}

```

---
Tags: solspace-user
---


title: Assets out of memory

text:
# Question
Title: Assets out of memory
memory\_limit is 2048M (from 7GB)

but I got error when indexed big amazon s3 folder

> PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 25415 bytes)

Tried add `$config['assets_memory_limit'] = 1024;` and `$config['memory_limit'] = 1024;`

EE 2.9.2, Assets 2.5

I see they already fixed this problem in version 2.3

* Fixed an issue where Assets could run out of memory when browsing large folders.

# Answer
> 3 votes
Fixed:

I found `ini_set('memory_limit', '64M');` in `/system/expressionengine/third_party/assets/sources/s3/source.s3.php` and changed it to `1024M`

---
Tags: assets, php-errors, s3, amazons3, php.ini
---


# Question
Title: Editors can't access the website when it's offline
I have a member group called "Editors" and I gave permission to the editors to be able to view the website when it's offline. They could access the control panel but they couldn't access the website unfortunately.

Sometimes I face the same problem as an Admin when I try to login to my account using windows computers. I tried to use different browsers but the problem would always occur.

Please help

# Answer
DevDemon's Smart Switch might help you with that.
> 0 votes

---
Tags: ee, offline
---


# Question
Title: Installing EE when existing cms site exists
Never been in this situation before so just wanted to make sure i do it correctly.

I am developing a new website (with EE), and currently a site/cms (non-EE) already exists on the server. What is the best way to set this up - meaning upload location/development site - so i can work on it without affecting the current site? Do I just create a folder in the root (named eg, new-site) and upload all EE files there, then go through the usual installation? Do i just change the two system\_path references to .new-site/system/ or is none of that necessary?

When i am working out pages/segments how would this work without causing any issues/ having to make coding changes after the site is live? (ie, example.com/new-site/template\_folder.... )

Is it better to create a subdomain and base url's on that (ie newsite.example.com) rather than just a 'folder'?

After everything is complete, do i just delete/remove the existing site form the root, then move all new site files out of the new-site folder?

Responses are appreciated.

# Answer
What we usually do is add a folder `ee/` to the root and install everything there. The base url will then be `http://yoururl.com/ee/` and ExpressionEngine will install everything accordingly and will ignore the subdirectory in segments.

When you go live (switch to the root directory) you will have to update the urls in General Configuration as well as any urls that you entered such as File Uploads path, template path, etc. which is usually not that bad. Try to use relative directory paths when possible.
> 1 votes

# Answer
Also, it is recommended that you 'll use a separate (second) database so the databases won't merge and you keep your database clean!
> 0 votes

---
Tags: subdomain, install
---


# Question
Title: How to redirect from front end to expression engine Admin panel
I tried login from front end and redirect it to adminpanel but it doesnot logged in to it. This is the code i tried.

{exp:member:login\_form return="www.sample.com/admin.php?/cp/homepage"}

Username

Password

{/exp:member:login\_form}

# Answer
> 1 votes
Unfortunately, logging into the front end will not log you into the EE control panel. You must re-login at admin.php

---
Tags: login, admin, admin.php
---


title: Store: Can't find product error

text:
# Question
Title: Store: Can't find product error
I'm adding Store to a site with a channel of existing products. Store installed correctly and works. I was getting this error when trying to add a product to my cart:

```
The form you submitted contained the following errors
Store: Can't find product (entry ID: 8238, modifiers [])

```

I figured out that if I add price to a product and save it in the Control Panel, it will allow me to add to cart. Since there are over 1000 products, I ran a sql to insert a row for each product entry\_id into exp\_store\_products with a price of 0 and the other columns default, as this is the data that appeared to change when I added a price and saved the first product.

I also added \[store\] to the custom Store field for the products channel, as that is what I saw in the products I had saved already.

I still get the same error with all products, though in the Control Panel edit page for the entries the price shows up. Unless I save each product, its not working. I looked for some array stored somewhere, a cache file, etc. of all the entries that Store considers products, but don't see one.

What else can I do in bulk to get all these products to add to the cart? I don't want to click save on 1000 products in the Control Panel.

# Answer
> 2 votes
You also have to update exp\_store\_stock with some basic info.

---
Tags: expresso-store, error, product
---


title: Weird URLs for images from Assets

text:
# Question
Title: Weird URLs for images from Assets
I'm troubleshooting a problem with an older, rarely updated site, so I'm not sure how recently this issue cropped up, though I'm fairly certain it worked when I handed it off. We have a Low Variable set as a Wygwam field using Assets for images. When we use Asssets to insert images into the field, we get an img tag with an src like this.

```
{assets_795:http://domain.com{filedir_5}1382581981.jpg}

```

Any idea what's going on there?

* EE 2.7.2
* Wygwam 3.2.2
* Assets 2.2.2
* Low Variable 2.4.0

UPDATE: It just occurred to me that the EE server this site lives on (which is multi-site) has had these add ons updated since I built the site, though I'm not sure how relevant that is to this particular issue.

# Answer
> 0 votes
How is the LV called? It should be called using the Parse or Single tag to process those unparsed vars, eg:

```
{exp:low_variables:single var="my_wygwam_var"}

```

---
Tags: assets, pixelandtonic, wygwam, low-variables
---


# Question
Title: Check to see if a product has been purchased - Expresso
Is there any way in expresso to check if the current user has purchased a particular product?

Something like, `{if purchased}you own this{if:else}you don't own this{/if}`

Thanks

# Answer
> 1 votes
You will need Stash to get this working

**Setting the stash**

`{if logged_in}
 {exp:store:orders member_id="CURRENT_USER" paid="yes"}
 {if is_order_paid}
 {exp:stash:append name="verify_product" trim="yes"}
 {items}{entry_id}|{/items}
 {/exp:stash:append}
 {/if}
 {/exp:store:orders}
 {/if}`

**Output the variables**

Wrap `exp:channel:entries` loop with `{exp:stash:parse process="end"}{/exp:stash:parse}`

Inside the entries loop

`{if "{exp:stash:verify_product}" ~ "/{entry_id}\b/"}
 You have already brought this map
{if:else}
 {exp:store:product entry_id="{entry_id}" return="{current_path}"}
 {if qty_in_cart}
 This product is already in your cart.
 {if:else}
 {price} <input type="text" name="item_qty" value="1" /> <button type="submit">Add to cart</button> <button type="submit">Add to cart</button>
 {/if}
 {/exp:store:product}
{/if}`

**Disclamer**: You will need latest version of EE to use the Matches operator conditional

---
Tags: expresso-store, expresso
---


# Question
Title: Difficult category search with Solspace Super Search
I need compose search string for this condition: Search in Home category and Cat or Dog. I tried like this: category=53&&236+47 but in don't work

I need only search string, Without form for searching

# Answer
> 0 votes
Unfortunately you cannot combine AND and OR searches at this time. I recommend submitting this as a Feature Request under the specific add-on category. It'll also give other users the option to vote up the feature request, and help us prioritize features to add in upcoming versions of this add-on. :) http://support.solspace.com/support/discussions

---
Tags: solspace, search, supersearch
---


# Question
Title: How to get the url_title of parent using Playa?
I need to generate a unique id for Playa child element so that an accordion works properly. For example:

```
{exp:playa:children field="doctors_locations"}
    <a href="#id-{count}-{url_title}" class="accordion-toggle">{locations_displayed_name}</a>
    <div id="id-{count}-{url_title}">...</div>
{/exp:playa:children}

```

The {count} tag gives me the row count of the Playa object. This results in:

```
<a href="#id-1-my-hospital-url-title" class="accordion-toggle">My Hospital Name</a>
<div id="id-1-my-hospital-url-title">...</div>

```

This Playa relationship is Doctors \> Locations - a one-to-many relationship. So, if the same location belongs to multiple doctors, I get duplicate ids on a list page.

In order to get a unique ID for each entry on this page, what I really need is the url\_title of the parent in this relationship. This is what I'm looking for:

```
<a href="#id-1-my-doctor-url-title" class="accordion-toggle">My Hospital Name</a>
<div id="id-1-my-doctor-url-title">...</div>

```

Again, this is a one-to-many (one doctor works at many locations), so I will get a unique ID for each if I can figure this out.

# Answer
Ok, got this figured out. You can embed a call to a Playa parent within the Playa child. I'm still using the var\_prefix to avoid collisions...

```
{exp:playa:children field="doctors_locations" var_prefix="loc"}
    <li class="accordion-navigation{if {loc:count} == 1} active{/if}">
        <a href="#id-{loc:count}-{exp:playa:parents limit='1'}{url_title}{/exp:playa:parents}" class="accordion-toggle location-name">{loc:locations_displayed_name}</a>
        <div id="id-{loc:count}-{exp:playa:parents limit='1'}{url_title}{/exp:playa:parents}" class="content{if {loc:count} == 1} active{/if}">...</div>
    </li>
{/exp:playa:children}

```

You need to make sure you set the limit='1' so the parent url\_title does not repeat for every iteration.
> 0 votes

# Answer
You could use the `var_prefix` parameter which is designed to help you avoid naming conflicts with variables in your template.

```
{exp:channel:entries channel="doctors"}
<!--
-- url_title = to parent url
-- and
-- loc:url_title = playa entry url_title
-->
  {exp:playa:children field="doctors_locations" var_prefix="loc"}
    <a href="#id-{loc:count}-{url_title}" class="accordion-toggle">
     {loc:locations_displayed_name}
    </a>
    <div id="id-{loc:count}-{url_title}">...</div>
  {/exp:playa:children}
{/exp:channel:entries

```

You will need to edit your template to prefix any of your playa children custom fields with `loc:` for them to be parsed correctly.
> 0 votes

---
Tags: playa
---


title: Structure interface breaking

text:
# Question
Title: Structure interface breaking
I am using structure in my current project and the interface is not displaying correctly. No files have been altered within the addon. Below you can see how my interface looks. Any Idea what would be causing this?

# Answer
> 2 votes
Just had a pretty bad issue like this, and after looking at the DB, I found the problem with lft/lgt. See: http://buildwithstructure.com/documentation/debug\_mode\_for\_page\_data/

My bug was resolved by fixing duplicates with the debug mode.

# Answer
> 0 votes
I am using the latest version. Not sure what the issue was exactly. Luckily enough it was quite earlier in the build. I uninstalled structured and then Installed again and it corrected the glitch. The interface would work correctly otherwise unfortunately. thanks :)

---
Tags: ee2, structure, ee2-upgrades
---


# Question
Title: Change in output for playa:parents inside Stash when going from PHP 5.3.x – 5.4.x
This template works fine on PHP 5.3.x:

```
{exp:stash:set parse_tags="yes" conditionals="yes"}

{stash:st_content}

  {exp:channel:entries
    channel="people"
    url_title="{segment_3}"
    dynamic="no"
    disable="categories|member_data|pagination|trackbacks"
  }
    {exp:playa:parents
      channel="projects"
      disable="member_data|pagination|trackbacks"
    }
    …
    {/exp:playa:parents}
  {/exp:channel:entries}

{/stash:st_content}

{/exp:stash:set}

```

but after upgrading to PHP 5.4.x, each project instead outputs the name of the people entry and no other content.

Anyone know why?

EDIT:

It seems that Stash isn't actually to blame here because if I remove Stash tags I get the same thing.

My expected output at a URL like /project/by/persons-name/ would be

* Project A
* Project B

etc. with only projects assigned to that person via the Playa field.

Instead, what I'm getting is

* Person's Name
* Person's Name

etc. for every entry in the projects channel.

The updated template with Stash taken out looks like:

```
{exp:channel:entries
    channel="people"
    url_title="{segment_3}"
    dynamic="no"
    disable="categories|member_data|pagination|trackbacks"
  }
    {exp:playa:parents
      channel="projects"
      disable="member_data|pagination|trackbacks"
    }
    …
    {/exp:playa:parents}
  {/exp:channel:entries}

```

# Answer
This is most likely happening due to a parsing conflict between `{exp:channel:entries}` and `{exp:playa:parent}` – the former is parsing your `{title}` tag before Playa can get to it.

The way to solve it is with Playa’s `var_prefix` parameter, which allows you to alias the tags that Playa is supposed be parsing, so that other tags won’t see them.

```
{exp:playa:parents
  channel="projects"
  disable="member_data|pagination|trackbacks"
  var_prefix="project"
}
    {project:title}
{/exp:playa:parents}

```
> 0 votes

---
Tags: playa, stash, php
---


# Question
Title: Any way to output a relative URL in exp:channel_files:files?
Our live environment is over SSL, but our local sandboxes aren't. This requires us to use {file:secure\_url} in our exp:channel\_files:files tag pair. Is there a way to output this URL that will inherit the protocol currently in use? Or a way to get the URL without the protocol or domain? I didn't see them in the docs.

The other issue I'm seeing is that the {file:secure\_url} and {file:url} tags are outputting a URL to the live (.com) site domain on my local sandbox which is (.dev) - I don't see how that is possible, looking in the channel\_files table. Any thoughts on that?

# Answer
> 1 votes
I might be missing something here, but in your `Control Panel > Administration > General Configuration` page, just set the `URL to the root directory of your site` setting to:

`//www.mysite.com/`

(replacing that with your site URL)

Same for the `URL to your "themes" folder` setting.

Using the double-slash with no `http` prefix means that it is protocol agnostic and accepts `https://` and `http://`. Your webserver does the rest.

# Answer
> 0 votes
This doesn't quite answer your specific question, but it might help anyway.

Normally when I've done SSL sites, which also haven't had local sandboxes serving SSL, I just use the config file to set the base URL and site URL conditionally with or without the https.

Focus Lab's Master Config already does this automatically. (excerpted below)

```
$protocol                          = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
$base_url                          = $protocol . $_SERVER['HTTP_HOST'];
$base_path                         = $_SERVER['DOCUMENT_ROOT'];
$system_folder                     = APPPATH . '../';
$images_folder                     = 'images';
$images_path                       = $base_path . '/' . $images_folder;
$images_url                        = $base_url . '/' . $images_folder;

$env_config['index_page']          = '';
$env_config['site_index']          = '';
$env_config['base_url']            = $base_url . '/';
$env_config['site_url']            = $env_config['base_url'];
$env_config['cp_url']              = $env_config['base_url'] . 'admin.php';
$env_config['theme_folder_path']   = $base_path   . '/themes/';
$env_config['theme_folder_url']    = $base_url    . '/themes/';
$env_config['emoticon_path']       = $images_url  . '/smileys/';
$env_config['emoticon_url']        = $images_url  . '/smileys/';
$env_config['captcha_path']        = $images_path . '/captchas/';
$env_config['captcha_url']         = $images_url  . '/captchas/';
$env_config['avatar_path']         = $images_path . '/avatars/';
$env_config['avatar_url']          = $images_url  . '/avatars/';
$env_config['photo_path']          = $images_path . '/member_photos/';
$env_config['photo_url']           = $images_url  . '/member_photos/';
$env_config['sig_img_path']        = $images_path . '/signature_attachments/';
$env_config['sig_img_url']         = $images_url  . '/signature_attachments/';
$env_config['prv_msg_upload_path'] = $images_path . '/pm_attachments/';

```

With something like this in place, you don't have to worry about relative paths, since the base path used for all path variables will include the correct protocol.

---
Tags: devdemon, ssl, channel-files
---


# Question
Title: Per form permissions for Solspace Freeform for different EE Member Groups: plugin examples that use EE Member Group privileges model
Expression Engine v2.9.2

I have a paid licensed version of the Solspace Freeform Pro (4.2.2) module. The current permissions model for this plugin does not allow Expression Engine Control Panel per-form viewing and moderation to different EE Member Groups. It allows permission settings on the parent Module only (which means access to all forms). This has been confirmed by Solspace support as of today (2015-03-26).

I have EE Member Groups that should only be permitted to view form submissions (and moderate said form submissions) that they have access to via the EE Control Panel. (I don't want to have to make a front-end templated interface to allow permitted users to approve at that level, although if left with no choice I will do that).

I am comfortable hacking at the Freeform Pro source code to add this feature, but I need some guidance/guidelines on applying the Expression Engine Permissions Member Groups module. I see the Expression Engine docs on the Cp::allowed\_group() method but it's pretty slim.

Specifically, if there are any third-party plugins that already use the EE Member Group level permissions model that I can take a peek at the source code to see how it has been done before within the EE Control Panel.

**EDIT 1:** This person has the same request but didn't get an answer.

**EDIT 2:** dashEE does this. That might be enough to get me going and/or I will contact the developer.

Thanks in advance.

# Answer
Sorry, if you're looking for that functionality in the CP (blocking access to specific forms per member group), that is currently not available. I recommend submitting this as a Feature Request under the specific add-on category. It'll also give other users the option to vote up the feature request, and help us prioritize features to add in upcoming versions of this add-on. :) http://support.solspace.com/support/discussions

On the front-end, however, you can do this using regular conditionals. For example, if your group\_id for "Marketing Member Group" is 7, then you could do something like this:

```
{if group_id == 7}
   /// Marketing Request form
{/if}

```
> 0 votes

---
Tags: solspace-freeform, solspace, members
---