title: Deprecation warnings for P&T Module Nav

text:
# Question
Title: Deprecation warnings for P&T Module Nav
Love this accessory by Brandon Kelly / P&T:

http://devot-ee.com/add-ons/module-nav

Works like a charm. Only now, I'm getting this error in the developer log:

```
Deprecated function generate_json() called in system/expressionengine/third_party/module_nav/acc.module_nav.php on line 82.
Deprecated since 2.6. Use the native JSON extension (json_encode()) instead.

```

Appears to still be working but the forum at devot-ee is closed. Anybody know if this is still supported by the developer? Or what to do to upgrade it? Tried swapping out the function but it failed.

# Answer
Try by replacing these `$this->EE->javascript->generate_json($lang, TRUE)` and `$this->EE->javascript->generate_json($modules, TRUE)` with `json_encode($lang)` and `json_encode($modules)`

I hope, it would work for you.
> 2 votes

# Answer
> Appears to still be working but the forum at devot-ee is closed

P&T staff are regularly on stack exchange so I'm sure they will stop by.

> I'm getting this error in the developer log

Unless you're actually an add-on developer, you should just disable the developer log warnings (I wish they were disabled by default). They are just that, only warnings, and they are really only useful to add-on developers who are in a position to fix the add-ons in question. They won't affect the stability or function of your website at all.

```
Deprecated function generate_json() called in system/expressionengine/third_party/module_nav/acc.module_nav.php on line 82.
Deprecated since 2.6. Use the native JSON extension (json_encode()) instead.

```

This is actually really easy to fix, and since the module is open source and on github I went ahead and fixed it and made a pull request. So if you want you can try my updated version.
> 2 votes

# Answer
You could always also head over to the main Pixel and Tonic web site to ask questions about this module. I know that they recently switched all purchase and distribution from their site to devot-ee, but they do offer support, including an email address you can use to contact them directly.

Looking on their site, though, it seems that this is not listed among their offerings. You may want to ask them directly (though they do regularly engage here, so maybe one of them will pop in and give information about long-term plans / development for that module.)
> 0 votes

---
Tags: pixelandtonic
---


# Question
Title: Displaying a category tree accordion with GWCode Categories & Bootstrap
Edited (now trying to get this to work for a 3rd level of categories)

I'm trying to get an accordion menu to work with bootstrap and GWCODE Categories. The problem I'm having is determining when a category depth starts and ends so that I can open and close divs appropriately. I have 3 main categories, multiple 2nd level categories, and multiple 3rd level categories. Here's the code I have so far which I'm trying to get to work for the third level of categories:

```
{exp:gwcode_categories  style="linear" group_id="1" depth="1|2|3"}
    {if depth1_start}
    <div class="accordion-group">
        <div class="accordion-level1-header">
        <!-- LEVEL 1 CONTAINER -->
        <h3><a href="{site_url}index.php/{complete_path}">{cat_name}  »</a> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#{cat_url_title}-level2"><span class="glyphicon glyphicon-plus-sign pull-right"></span></a></h3>
        </div>
        {/if}
        {if depth2_start}
        <!-- LEVEL 2 CONTAINER -->
          <div id="{parent_url_title}-level2" class="accordion-level2 collapse">
        {/if}
          {if depth==2}
            <div class="level2-item"><a href="{site_url}index.php/{complete_path}">{cat_name}  »</a> <a data-toggle="collapse" data-parent="#accordion" href="#{cat_url_title}-level3"><span class="glyphicon glyphicon-plus-sign pull-right"></span></a></div>
          {/if}
            {if depth3_start}
            <!-- LEVEL 3 CONTAINER -->
              <div id="{parent_url_title}-level3" class="accordion-level3 collapse">
            {/if}
              {if depth==3}
                <div class="level3-item"><a href="{site_url}index.php/{complete_path}">{cat_name}  »</a></div>
              {/if}
          {if depth3_end}
            </div><!-- END OF LEVEL 3-->
          {/if}
        {if depth2_end}
          </div><!-- END OF LEVEL 2-->
        {/if}
    {if depth1_end}
   </div> <!-- END OF LEVEL 1-->
   {/if}
{/exp:gwcode_categories}

```

The HTML that is output:

```
<!-- LEVEL 1 CONTAINER -->
  <h3><a href="#">Data Solutions  »</a> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#data-solutions-level2"><span class="glyphicon glyphicon-plus-sign pull-right"></span></a></h3>
</div>
<!-- LEVEL 2 CONTAINER -->
<div id="data-solutions-level2" class="accordion-level2 collapse">
  <div class="level2-item"><a href="#/copper">Copper  »</a> <a data-toggle="collapse" data-parent="#accordion" href="#copper-level3"><span class="glyphicon glyphicon-plus-sign pull-right"></span></a></div>
  <!-- LEVEL 3 CONTAINER -->
  <div id="copper-level3" class="accordion-level3 collapse">
    <div class="level3-item"><a href="#/copper/copper-cable">Copper Cable  »</a></div>
    <div class="level3-item"><a href="#/copper/copper-connectivity">Copper Connectivity  »</a></div>
    <div class="level3-item"><a href="#/copper/plastics">Plastics  »</a></div>
  </div>
  <!-- END OF LEVEL 3-->
</div>
<!-- END OF LEVEL 2-->
<!-- LEVEL 2 CONTAINER -->
<div id="data-solutions-level2" class="accordion-level2 collapse">
  <div class="level2-item"><a href="#/fibre">Fibre  »</a> <a data-toggle="collapse" data-parent="#accordion" href="#fibre-level3"><span class="glyphicon glyphicon-plus-sign pull-right"></span></a></div>
  <!-- LEVEL 3 CONTAINER -->
  <div id="fibre-level3" class="accordion-level3 collapse">
    <div class="level3-item"><a href="#/fibre/fibre-cable">Fibre Cable  »</a></div>
    <div class="level3-item"><a href="#/fibre/fibre-connectivity">Fibre Connectivity  »</a></div>
  </div>
  <!-- END OF LEVEL 3-->
</div>
<!-- END OF LEVEL 2-->

```

# Answer
Your code looks good to me, but maybe try adding the `depth="1|2"` parameter.
> 1 votes

---
Tags: categories, gwcode-categories
---


# Question
Title: Problem with using conditionals on nested Playa children tag
Any idea why this conditional is not working? If I remove 'if' the code renders desired result.

```
{exp:channel:entries channel="festivals" url_title="festival-2013" limit="1"}
        {exp:playa:children channel="films" var_prefix="films"}

        {if '{films:film_language}' != ""}
            {films:exp:playa:children channel="languages" var_prefix="filmlanguage" backspace="1"}
                {filmlanguage:title},
            {/films:exp:playa:children}
        {/if}

            {/exp:playa:children}
 {/exp:channel:entries}

```

# Answer
> 1 votes
The single tag `{films:film_language}` will never return empty. Try it by itself in your template and see what you get. A `0`, I think (don't remember).

If there's nothing for the Playa field to parse, if it's empty, then it won't show, so just do this:

```
    {films:film_language}
        {exp:playa:children channel="languages" var_prefix="filmlanguage" backspace="1"}
            {filmlanguage:title},
        {/exp:playa:children}
    {/films:film_language}

```

Does that solve it for you?

---
Tags: playa
---


# Question
Title: Checking if there are any related entries
I'm building what I imagine to be a fairly stock-standard page template on a very standard EE setup.

I'm attempting to use EE 2.6.1's new native Relationships field type to link articles to each other, and to pages from another channel.

What I need to do is check if there are any related articles for the current page/article *before* I spit out the related content (if it's there). This is mainly so I can show or hide the "Related Articles" as appropriate.

My basic code looks like this:

```
{if related_articles}
    <h3>Related Articles</h4>
    {related_articles}
        {related_articles:title} (etc...)
    {/related_articles}
{if:else}
    There are no related articles.
{/if}

```

This just returns the message about there being no related articles.

However, if I take the `{related_articles}` loop out of the conditional, it performs exactly as expected.

This type of check would work just fine with any other type of channel field variable, so I'm a little confused as to why it's not working here.

I've checked over the official Relationships documentation a couple of times, but it doesn't seem to mention this type of scenario.

Am I doing something wrong, or missing something obvious? Is this something that can be achieved with EE's new native relationships?

**Update:** Ok, shortly after posting this I found this question, the answer to which helped me out.

I find the solution to be a little messy (nesting my title and any opening and closing DIVs within the loop itself - potentially necessitating multiple conditionals within the loop) but it gets the job done.

# Answer
That won't work as the relationship is a tag pair, so at it's basic you could use:

```
{if "{related_articles}{related_articles:title}{/related_articles}"}
    <h3>Related Articles</h4>
    {related_articles}
        {related_articles:title} (etc...)
    {/related_articles}
{if:else}
    There are no related articles.
{/if}

```

But that's really clunky.

The documentation isn't great, but reading the comments from the docs, Hop Studios has the solution:

```
 {parents field="my_field"}
   {if parents:no_results}NOTHING FOUND{/if}
   (<a href="{comment_url_title_auto_path}">{parents:title}</a> {count} {parents:count})
 {/parents}

```

So at a guess, try this:

```
{related_articles}
    {if no_results}
        There are no related articles.
    {/if}
    {if count == 1}<h3>Related Articles</h3>{/if}

    {related_articles:title} (etc...)
{/related_articles}

```

This **may** also work...

```
{if related_articles:no_results}
    ...
{if:else}
    ...
{/if}

```

FYI: Your original... `<h3>Related Articles</h4>`
> 3 votes

---
Tags: ee2, templates, relationships
---


# Question
Title: Is there a way to get the list of languages in the frontend?
In the control panel, if you go to

Admin -\> General Configuration

there is an option for setting the default language. The select dropdown contains the list of languages that are supported.

Is there a way to get this list of languages either in the templates or inside a plugin function?

# Answer
I am not sure if there is any template tag for it but all the languages can be fetched with code.

Basically all the language options displayed from the installed language packs within the directory "system/expressionengine/language/". I think, you can develop a small plugin for it with the following code example:

```
ee()->load->model('admin_model');
$languages = ee()->admin_model->get_installed_language_packs();

```

See `$languages` is an array of all languages.

I hope, it would help you.
> 2 votes

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


# Question
Title: Why am I getting a "duplicate page uri" error when leaving the field blank?
Running EE on windows server and I get the "duplicate page uri" error when editing any entry. I don't want these as pages, but I can't save without creating a unique page url for them...

# Answer
If that page has been added to the Pages module list, it will require a URI. And if you've left at least one other blank, then that's where your duplicate URI is coming in. Just check out the Pages module list and make sure you delete the page from there -- it won't actually remove the page entry in the channel though.
> 2 votes

---
Tags: error, pages, windows, iis
---


title: Track logged-in user events

text:
# Question
Title: Track logged-in user events
Have a site that has hundreds of PDF files which users can access once they create an EE member account.

Client is asking if there is a way to track which files the user has downloaded and either log them against their account or email the client with a report at the end of a session.

Has anyone come across a plugin or third party system that would achieve this?

# Answer
> 4 votes
This can be achieved by developing a small custom third party addon (module) and some Ajax stuff. I think, you are having PDF file linked in HREF so there would an event be triggered on click at that PDF link with Ajax call.

* A small module would be created which will create a database table to track all the downloads
* This module would have an ACTION which will trigger with Ajax call on clicking the PDF link. Like: `$.post("?ACT=xx", { pdf: "xyz",
entry_id: "xxx", other_data : "abc" } );`
* The module function associated with that ACTION will do (1) Store the member id and downloaded PDF into database table (2) Send an email notification to admin.

Above is the whole approach for your need. I hope, it would help you and give some idea for developing that module.

# Answer
> 2 votes
I would suggest checking our either Link Vault or Protected Links both are quite similar and work very well for what you're looking to do.

---
Tags: ee2, members, analytics
---


# Question
Title: Add custom field output to Structure row
Using Structure to manage a bunch of content and I'd love to show the value of a single custom field to the right of the title. It is just a number field to identify a piece of artwork. I imagine there may be a hook or something to grab onto within Structure and grab the value, but I was wondering if anyone had done this before and had any advice to offer?

I do know that I could go the route of Zenbu to show more customized information in a standard channel entries display, but I'd prefer to keep my client in the Structure world if possible.

Thanks!

# Answer
> 1 votes
You'll need an Extension that taps into the structure\_index\_view\_data hook:

```
function activate_extension() {
    $hooks = array(
        "structure_index_view_data" => "customise_structure"
    );

    foreach ($hooks as $hook => $method) {
        $data = array(
            'class' => __CLASS__,
            'method' => $method,
            'hook' => $hook,
            'settings' => "",
            'priority' => 10,
            'version' => $this->version,
            'enabled' => 'y'
        );
        $this->EE->db->insert($this->EE->db->dbprefix . 'extensions', $data);
    }//###   End of foreach   ###
}//###   End of activate_extension function

```

Then in your customise\_structure method:

```
function customise_structure($data) {
    if ($this->extensions->end_script === TRUE)
        return $data;
    if ($this->EE->extensions->last_call !== FALSE)
    $data = $this->EE->extensions->last_call;

    foreach($data["data"] as $tab_id => $content) {
        foreach($content as $eid => $page) {
            //Use $page['entry_id'] to get the entry ID
            //Use $page['title'] to append and customise the row display

            ...

        }//###   End of foreach   ###
    }//###   End of foreach   ###
    return $data;
}//###   End of customise_structure function

```

Using the entry\_id you could run a query for each loop getting the custom field then appending it to $page\["title"\] with relevant spacing or span to indent or style further.

Be warned though, do a query per loop would be consuming, you'd be better to do an initial loop building the entry\_id list, then build a single SQL getting just the single custom field you require for all the entries.

This should be enough to get you up and running on building your own extension.

# Answer
> 0 votes
You can use a normal channel tag to show any custom fields you want. If it's not data that is part of the current page URL, you'll need to specify the entry\_id and use dynamic="no".

---
Tags: structure
---


# Question
Title: EasyPost integration with Exp:resso Store
Has anyone tried integrating EasyPost with Exp:resso Store? They seem like a good fit, and I might have a go at it myself if necessary, but I don't want to duplicate anybody's work.

Alternately, is there a basic template for a Store shipping module that I can start from?

# Answer
> 1 votes
I don't know of anyone that has implemented EasyPost with Store. Store's shipping gateways are undergoing a major overhaul in how they function from v1 to v2 (which is under active development now). Depending on your timeframe I would recommend waiting for v2 to be released (or emailing support@exp-resso.com to see about getting added in to the beta).

There is not an example shipping module per say but you can look at the UPS/USPS/FedEx plugins in the current version of Store to see how things are setup currently as a great starting point. In v2 the shipping plugins are handled as extensions which should make them easier to create and extend.

---
Tags: expresso-store, module, shipping
---


title: Overriding the default/loaded language

text:
# Question
Title: Overriding the default/loaded language
I am making my site multilingual and the solution that I went with is to leverage CI's language system(that is, I am using language files).

I am using this addon to access language variables from the language files. Here is the code used to retrieve the language strings

```
$lang_file = ($this->EE->TMPL->fetch_param('file')) ? $this->EE->TMPL->fetch_param('file') : 'custom_label';

$this->EE->lang->loadfile($lang_file);

$param = $this->EE->TMPL->fetch_param('value');

$string = ($this->EE->lang->line($param)) ? $this->EE->lang->line($param) : '';

return $string;

```

I noticed though that no languages was set here. So I assumed that it is being set somewhere before this code executes.

I tried changing the languages in the *Localization Settings* for each member and the addon worked, getting only the strings from that language.

That is all well and good but it does have a problem in particular.

> The current system only works for members. What if a guest(logged out user) wants to change language?

Solutions I am currently thinking are

1. Instead of relying on the saved preferred languaged, I would base it on the url segment

http://domain.com/en/test and http://domain.com/fr/test
2. Store the language code in session

However, both of this can only work if I can override the currently set language.

Is there a way to do this?

P.S. Please don't suggest using addons like Publisher or Transcribe. I want to do this without using those addons.

# Answer
> 2 votes
You need to set the language code each time when a page loads. I think, you would know that a language can be set with config variable (within config.php) like: `$config['language'] = 'english';`. You should have the same logic and use the hook `sessions_start`. Within the hooked extension you can set the language like `$this->EE->config->_global_vars['language'] = 'french';`

Also, I think it would be good to set language in cookie so Global Var's language value can be assigned from cookie to avoid getting the language again and again from URI (with language code like http://domain.com/fr/test).

I used this method about 6 months ago so not sure about the exact code to share with you. Although, I hope it would help you.

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


# Question
Title: Any way to create a custom price modifier?
Here's what I want to do. I have a store with a variety of products. some of the products have price modifiers (like custom color, or "base price").

The products have a price per quantity. But, the products also have a base price. Additionally, if a customer selects a custom color, then there is a price modification. But, I don't want the base price, or the custom color price modification to apply to every quantity of that product. Just once per product in the cart.

example: These are products that are typically purchased in quantity (think holiday cards). Each product (the card type) has a minimum order quantity (25). Even though there is a minimum quantity purchase of 25, I'm managing the pricing per unit (so the store will do all the price calculations, and so the customer can adjust quantity in the cart). So, the per unit price is $5. There is a price modifier for color. There is Black (+$0), White (+$0), and Custom Color (+$30).

If the customer orders this card at a quantity of 50 in white, the price will be: $250 ($5 x 50)

If the customer orders this card at a quantity of 50 in a custom color (they specify the color), the price will be: $280 ($5 x 50 = $250 + $30) (the custom color charge is a one-time charge. Not a per unit charge).

The "base price" functionality (I'm calling it base price, but it's really a "set up cost for die cutting of certain versions of the cards) can function the same.

Example. Card A has a per quantity cost of $5. But, because this is a special type of printing, it requires a one-time setup cost of $50. So, the price modification is the same as the custom colors above (only the customer doesn't get to choose whether this modifier is selected, it's automatically chosen).

I have a lot of different products, and the setup cost is different for each product type. I could do the math and come up with some formula that allows me to include the setup cost in the per unit cost. But, the set up cost may change over time, where the actual per unit cost will not. Additionally, if a customer comes back and purchases more of one of the items that they already purchased, then they do not get charged that setup cost. So, ideally, I'd like to keep it away from the per unit cost, and use it just like the custom color scenario... and in the templates I can just hide that modifier option and make it apply automatically.

Clearly, this isn't an option in the expresso store. Is there a way to create a custom price modifier type/module/add-on that I could use? Or, any other approach for managing this? (my fall-back method is to find in the code where the price modifier math is being done and change it from a "multiply against every unit" to a simple "add once per product in the cart". I realize that won't survive software updates... But ALL products would operate this way.. So, I wouldn't have the need to have a standard price modifier function.)

Thoughts?

# Answer
There are two ways I can think of to achieve this.

The first would be to actually make your "custom color price" a whole separate product. Since you can add multiple products to the cart at once, you could let the customer choose a custom color, and add this (with a qty of 1) to the cart along with the correct # of cards. If your customer usually only order one product at a time then this would be a reasonable solution, because your customers will see the qty of items they ordered, plus a surcharge for the custom color in their cart. However, if each product has a different custom color surcharge then it could get a bit out of hand.

The second solution is to write an extension. Explaining the basics of extension development is out of scope for this answer, but if you're familiar with it (or have a PHP developer at your disposal), you can use the store\_cart\_item\_update\_end hook to reset the item price every time the cart is updated. With this method you could use a custom field to store the "setup price" and "custom color price" for each product, and then query these and update the cart price based on any modifiers selected for that product.
> 2 votes

---
Tags: expresso-store
---


# Question
Title: Expresso Store orders suddenly not getting past checkout 3 to Paypal
A website belonging to a client of mine suddenly stopped working. She assures me no changes have been made. It's been 5 days since her last successful online order, and she usually gets several per week. Someone trying to order alerted her to the problem. We have both tried buying something through the site, and neither of us can get past Checkout step 3, where you click place order and go to Paypal. I checked the Paypal API credentials (we're using Paypal express as the gateway), and they are correct. I removed the inline errors and it's still spinning and spinning until it times out, without giving any clue as to what's wrong. The page finally shows a Gateway Time-Out. The website has been working successfully for a couple of years. We are running Store 1.6.3 and EE v2.5.5.

# Answer
> 1 votes
Turns out the problem was with the web host, 1&1. They didn't want to disclose what they did to cause or fix the problem, but it is now sorted.

---
Tags: expresso-store, paypal-express-checkout
---


title: Matrix Day Calendar

text:
# Question
Title: Matrix Day Calendar
We are using Matrix to make a company calendar. We would like to enter the events into a matrix table one month at a time but display only the current day's events. We are trying to search a matrix date field and check if it matches the current day.

```
{schedule search:date="={current_time}" sort="asc"}

```

Has anyone done this before? Suggestions/help is much appreciated.

Thanks

# Answer
> 1 votes
The search condition would never match as {date} and {current\_time} both output the UNIX Time (number of seconds since 1 January 1970). You would need to have IF condition with MATRIX variable tag like:

```
{schedule orderby="date" sort="asc"}

{if "{date format='%Y%m%d'}" == "{current_time format='%Y%m%d'}"}

{!-- Put other tags here --}

{/if}

{/schedule}

```

---
Tags: matrix, pixelandtonic, calendar
---


# Question
Title: Solspace Freeform Pro 4.0.12 Not Sending notify_user email
I'm having some troubles with Freeform Pro.

I've got my forms working correctly, using the {exp:freeform:form} tag, the information is being logged into Freeform correctly, the Admins are getting the email, but the notify\_user template doesn't seem to be working. I've read the documentation and it looks as if you have to use "notify\_user", "user\_email\_field", and "user\_notification\_template" all together. I've got all three params in my Freeform tag, but cannot seem to figure out why they're not getting the email.

I'm using Ajax to send the forms and to run simple validation, but I don't think that would have any effect on the user emails, would it?

Here's my code:

```
    {exp:freeform:form form:class="jqtransform form_main" form_id="4" required="first_name|where_do_you_live|user_message" return="your-dreams-goals" admin_notify="my_email@address.com" notify_admin="yes" notify_user="yes" user_email_field="email" user_notification_template="default"}
    <input type="text" id="first_name" name="first_name" placeholder="First name" />
    <input type="text" id="where_do_you_live" name="where_do_you_live" placeholder="Where do you live?" />
<textarea id="user_message" name="user_message" rows="5" cols="15" placeholder="Click here to type your dream or goal...">Click here to type your dream or goal...</textarea>

<div class="clear"></div>
<p class="purple">Would you like to send your dream or goal to yourself?</p>

<span>
<input type="text" class="input" name="email" id="email" placeholder="Email Address" />
<label for="email" class="float-left">(Optional)</label>
</span>

<div class="clear"></div>

<span>
<input type="checkbox" id="accept" class="checkbox" />
<label for="accept" class="checkbox-label">By checking this box, you agree to share your Dreams and Goals on our website and other social media sites like Facebook and Twitter for others to see and enjoy.  We might also show them in our IPMG written materials.  We would only use your first name and city.  If you do not want us to show your Dreams and Goals, do not check this button, and they will be kept private.</label></span>

<input type="submit" class="cta float-left" id="form-main" onclick="return ValidateForm();" {/exp:freeform:form}

```

I have a notification template called "default" saved in Freeform.

Any ideas as to what may be going on? Any help would be appreciated.

Thanks!!

# Answer
> 0 votes
Can you try a really simple contact form, name, email with out anything else in the template so we can make sure FF is functioning properly with out any other scripts potentially effecting the behavior?

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


# Question
Title: Related calendar custom fields from an event
Is is possible to get custom field data of a calendar from a related event? Basically I want to be able to assign colors to calendars as a custom field, and then within the `{events}` variable pair set the background color of an event based on which calendar it belongs to. So something like:

```
{exp:calendar:cal date_range_start="year-month-01" ... }

  {display_each_day}

    {date format="%J"}

    {events}

      <article style="background-color: #{calendar_color};">
        <h1>{event_title}</h1>
      </article>

    {/events}

  {/display_each_day}

{/exp:calendar:cal}

```

The above code will only output a blank string for the `{calendar_color}` custom field (I assume this is because the `{exp:calendar:cal}` tag by default will output multiple calendars).

So basically I'm just looking for a way to create a reverse relationship from the event to the calendar based on the relationship that is already setup between calendars and events with Solspace Calendar.

# Answer
> 1 votes
Yes you can call relationships inside calendar events. You need to follow the correct syntax just as if this were a regular calendar:entries tag. ref http://ellislab.com/expressionengine/user-guide/modules/channel/relationships.html

---
Tags: solspace-calendar
---


title: File path disappears when logged in

text:
# Question
Title: File path disappears when logged in
I created a simple member's area, where people can login and download PDFs.

When I created the new member group, create a new member, and login as them – **all** file paths are disappearing on the front-end, meaning while the new member's login session is active, no path links are displaying when viewing the site/templates, in any sections. All other tags are coming out as normal.

The original paths are in a file field in a Matrix row – but I also created a basic file field to test (native), but still it is not showing paths.

I can't seem to find any occurrences or similar problems to this.

When I am logged in as Super Admin all is working as expected, it is **only** when I login as a member from this new member group, file paths disappear on front end.

I'm on EE v 2.5.3.

Thanks in advance! Glen

# Answer
Sounds like a permissions issue with your upload folders. Make sure in file manager \> file upload preferences that your new member group has access.
> 1 votes

---
Tags: ee2, members, files
---


# Question
Title: expression engine super search module : group by issue
I am using supersearch module, here is link for doc of its http://www.solspace.com/docs/super\_search. Actually I am facing a problem that is to get records group by.

Using this module i dont know how to get the entries group by channel. I want the entries result group by its channel.

This is my code: Search :

```
<form method="post" action="{path='search/results'}/" style="padding-top: 15px;">
    {exp:super_search:search}

    <input type="text" name="title" value="" style="height: 31px;"/>
    <input type="submit" value="Search" />

    {/exp:super_search:search}
</form>

```

Result :

```
{exp:super_search:results paginate="both" limit="10"}

{channel_name}<br/>
{title} <br/>

{paginate}<p>Page {current_page} of {total_pages} pages {pagination_links}</p>{/paginate}
{/exp:super_search:results}

```

there are 5 channel in my project and each channel having at least 15 records. I want all record group by channel.

Can anybody tell how can I get the records what I exactly wants.

Sorry for my bad English Thanks.

And Yes I want the Records like below mention : \[if possible please suggest for the same\]

```
Channel -1 --entry-1 --entry-2 --entry-3 --entry-4

Channel -2 --entry-1 --entry-2 --entry-3

Channel -3 --entry-1 --entry-2 --entry-3

```

Continuous like this..

# Answer
In your Results loop you could add:

```
orderby="channel_name"

```

You would then want to store the last items channel\_name and compare it to the current items channel\_name to find when you wanted to actually output the channel\_name to the screen.
> 1 votes

# Answer
I didn't have a chance to test this, and make sure you have php enabled on your template, but try something like what is below:

```
<?php $prev_channel = ""; ?>

{exp:super_search:results orderby="channel_name" paginate="both" limit="10"}

{if channel_name != "<?php echo $prev_name?>"}
    {channel_name}<br/>
{/if}
{title} <br/>
{paginate}<p>Page {current_page} of {total_pages} pages {pagination_links}</p>{/paginate}
<?php $prev_name = {channel_name}; ?>

{/exp:super_search:results}

```
> 0 votes

---
Tags: search, query
---


title: EE2: Captcha if statement not working

text:
# Question
Title: EE2: Captcha if statement not working
I am trying to add a captcha to a site that is running EE 2.6.1. I am using solspace freeform 4.0.12 (the free version, not pro) and accessible captcha 2.3. The code for the captcha is

```
<tr>
    <td colspan="2" style="margin-left:144;">
        {if captcha}
            <p>{captcha}<br /> <input type="text" name="captcha" value="" size="20" maxlength="20" style="width:140px;" /></p>
        {/if}
    </td>
</tr>

```

When I remove the {if captcha} tags, the question/answer pair shows up, but it also allows the form to be submitted with an incorrect or missing answer.

I have also tested the page on multiple browsers to make sure that I'm not logged in.

Any suggestions?

# Answer
For our FreeForm forms, we use the following code:

```
{if freeform:captcha}
      {freeform:captcha}<input type="text" name="captcha" style="width:140px;" />
{/if}

```
> 4 votes

---
Tags: ee2, solspace-freeform, captcha
---


title: My custom plugin won't install. Why?

text:
# Question
Title: My custom plugin won't install. Why?
I copied an online example exactly, named it appropriately, placed it in the plugin folder, and (I think) changed the location attribute to match the other plugins in my plugin folder. The code is below.

File Name: `pi.auto_acronym.php`

```
<?php
    $plugin_info       = array(
    'pi_name'        => 'Auto Acronym',
    'pi_version'     => '1.0',
    'pi_author'      => 'John G',
    'pi_author_url'  => 'http://google.com',
    'pi_description' => 'Automatically wraps certain acronyms in the HTML <acronym> tag',
    'pi_usage'       => Auto_acronym::usage()
    );

class Auto_acronym{
    function Auto_acronym(){
    }
    // ----------------------------------------
    //  Plugin Usage
    // ----------------------------------------
    function usage()  {
        ob_start();
        ?>
        This is where our simplified documentation will go
        <?php
        $buffer = ob_get_contents();
        ob_end_clean();
        return $buffer;
    }
}
/* End of file pi.auto_acronym.php */
/* Location: ./system/expressionengine/plugins/pi.auto_acronym.php */

```

This file is indeed placed in my `.\PROJECT_NAME\system\expressionengine\plugins` folder. There are other plugins in the folder that came with the install.

Edit: I just noticed that there is a missing '?\>' at the end of the plugin. I tried completing the block, but it still didn't work. I checked the other plugins, they too all have that missing closing php block. So that isn't the issue.

**Edit 2: Based off Rob Sanchez's suggestion, which solved my issue**. I moved my plugin to the third-party folder as follows.

File Name: `pi.auto_acronym.php`

```
<?php
    $plugin_info       = array(
    'pi_name'        => 'Auto Acronym',
    'pi_version'     => '1.0',
    'pi_author'      => 'John G',
    'pi_author_url'  => 'http://google.com',
    'pi_description' => 'Automatically wraps certain acronyms in the HTML <acronym> tag',
    'pi_usage'       => Auto_acronym::usage()
    );

class Auto_acronym{
    function Auto_acronym(){
    }
    // ----------------------------------------
    //  Plugin Usage
    // ----------------------------------------
    function usage()  {
        ob_start();
        ?>
        This is where our simplified documentation will go
        <?php
        $buffer = ob_get_contents();
        ob_end_clean();
        return $buffer;
    }
}
/* End of file pi.auto_acronym.php */
/* Location: ./system/expressionengine/third_party/auto_acronym/pi.auto_acronym.php */

```

The above file is placed in the `./PROJECT_NAME/system/expressionengine/third_party/auto_acronym/` folder.

# Answer
You need to make a folder in your `system/expressionengine/third_party` folder called `auto_acronym` and place your plugin file in there.
> 3 votes

---
Tags: plugin
---


# Question
Title: Notice in Log file: Use of undefined constant REQ - filling up log files
On several of my EE2.6.1 websites I am noticing that the log files are getting bloated with the following notice over and over again:

`ERROR - 2013-08-26 13:10:20 --> Severity: Notice --> Use of undefined constant REQ - assumed 'REQ' /home/highland/public_html/system/expressionengine/libraries/Core.php 48`

Is anyone else getting this in their logs? Have any idea how I can fix this or what it means?

Thanks!

# Answer
> 1 votes
This looks like an EE bug to me, I'd report it to EllisLab.

The error you are seeing comes from system/expressionengine/libraries/Core.php, on this line in the constructor:

```
@set_time_limit((REQ == 'CP') ? 300 : 90);

```

However, REQ isn't actually defined until the bootrap() method a bit further down:

```
public function bootstrap()
{
    // Define the request type
    // Note: admin.php defines REQ=CP
    if ( ! defined('REQ'))
    {
        define('REQ', ((ee()->input->get_post('ACT') !== FALSE) ? 'ACTION' : 'PAGE'));
    }

```

So unless I'm missing something obvious, it seems correct to throw an error for accessing a constant before it has been defined. If this is a bug though, I'm surprised more people aren't reporting it.

---
Tags: ee2, error, core
---


title: Channel Images and IIS paths

text:
# Question
Title: Channel Images and IIS paths
I'm trying to use channel images on a Windows server, but channel images uses a '/' for the paths on the actions instead of letting me use ' \\'. Anyone have a fix for this?

# Answer
> 1 votes
Turns out I was trying to outsmart the server by adding extra forward slashes. Removed those and it worked perfectly.

---
Tags: channel-images, windows, iis
---


title: Differentiate Playa entries

text:
# Question
Title: Differentiate Playa entries
Is there a way in the control panel to differentiate between channel entries that have the same title? We have a 'related course' field that looks at courses and have several 'science' courses that are further defined by category but there's no way to see this.

We need to be able to choose any course but also see its category.

# Answer
You can hack Playa to show custom fields, etc.–the downside is that it displays that information for every Playa field. See more here: Filter Playa List by Custom Field
> 0 votes

---
Tags: playa, pixelandtonic
---


# Question
Title: Expression Engine + Solspace Rating Module - "Vote Up" a customer review
Can you vote 'up' a review using Solspace Rating so that it'd do something like:

'5 out of 8 people found this review useful'

I've had a good look through the docs but don't see anything like this...

Thanks.

# Answer
> 1 votes
It would appear so!

http://www.solspace.com/docs/rating/rating\_vote\_stats/

This does exactly what I need.

# Answer
> 1 votes
I have seen other instances where people did not want to "vote up" the rating itself, but they wanted to "like" the product itself that you may be able to rate.

In order to get this functionality, people have used the Solspace Favorites plug-in.

Just thought I would add this info in case people run across this need too.

---
Tags: solspace-rating
---


# Question
Title: How do I hide or delete "open" and "closed" statuses from a custom status group?
I've created a custom status group in EE 2.6.1. I'd like to use my own statuses (draft, ready, send, sent) and I want to remove "open" and "closed", or rename them. What's the easiest way to get rid of the default open and closed status choices?

# Answer
> 3 votes
You can't delete those as open is a default status parameter for channel entries. What you can do is create your custom status, and only give your client access to the custom statuses. This way Open and Close never show up.

---
Tags: status, delete, custom
---


# Question
Title: Quick and safe way to delete all entries with a given status?
Due to a data grab import that went a bit awry I find myself with approx 10000 entries that I don't want! They've all got a specific status.

I'm currently deleting them in batches but the most I can do is 200 at a time and it's getting a bit boring.

Is there a quick and safe way to delete them all - perhaps using SQL (but which leaves things clean and tidy)?

Let's see if I can get an answer before I've finished manual deletion. :)

# Answer
This SQL will clean up both `exp_channel_titles` and `exp_channel_data`:

```
DELETE exp_channel_titles, exp_channel_data
FROM exp_channel_titles
INNER JOIN exp_channel_data
ON exp_channel_data.entry_id = exp_channel_titles.entry_id
WHERE exp_channel_titles.channel_id = 5
AND exp_channel_titles.status = 'your_custom_status'

```

Replace the channel\_id and status as appropriate. But as Jeremy's answer says, you might need to consider other tables!

A related discussion is in "What is the best way to delete every entry in a channel?"
> 3 votes

# Answer
Using SQL to remove entries means you also have to do extra clean up on relationship tables and categories.

You can bypass the input limits by appending the appropriate query string parameters to the address of the edit screen. For example, go to Publis \> Edit \> Your Channel. Then append the following to the url: &perpage=5&status=closed

You should get only 5 entries who's status is closed. You could change this to 500 I suppose to do what you're asking.

**I would limit this to 500 or so to prevent the server from timing out.**

-N
> 2 votes

# Answer
SQL seems like the way to go. The hardest part would be to make sure that any add-ons you're using that have their own tables of entries get wiped out too. (such as Playa, Matrix, etc)

Beyond those special cases, the only tables you really have to worry about are exp\_channel\_titles, exp\_channel\_data and exp\_category\_posts and exp\_relationships if you're using relationships.
> 0 votes

# Answer
As suggested, SQL is the *best* way to do this in bulk.

The query is as follows:

```
delete exp_channel_titles, exp_channel_data
from exp_channel_titles
inner join exp_channel_data on exp_channel_data.entry_id=exp_channel_titles.entry_id
where exp_channel_titles.status="MyCustomStatus"

```

NOTE: In my case I wasn't using any relationships or categories
> 0 votes

---
Tags: entries, sql, delete
---


title: Stash get within the same set

text:
# Question
Title: Stash get within the same set
Can't quite figure this one out. Trying to set and then get "program\_sponsor" within stash:content

program\_sponsor is returning blank with stash:get

```
{exp:stash:set parse_tags="yes" parse_conditionals="yes"}
    {exp:switchee variable="{segment_2}"}
        {case default="yes"}
            {stash:content}
                {exp:channel:entries channel="programs" url_title="{segment_2}" dynamic="no" limit="1"}
                    {stash:program_sponsor}
                        <p>Who loves bacon?</p>
                    {/stash:program_sponsor}
                {/exp:channel:entries}

                {!--
                    chunck of other channel entry code goes in-between here
                --}

                {!-- Need to output this variable set earlier above --}
                {exp:stash:get name="program_sponsor"}

            {/stash:content}
        {/case}
    {/exp:switchee}
{/exp:stash:set}

```

# Answer
Tried parse="inward" on the switchee tag which caused nothing to return.

Also tried parse\_depth="2" on the exp:stash:set tag.

To fix this I stripped out the stash:program\_sponsor from stash:content and made more separation rather than setting a stash variable within a variable expecting then to grab it later in the same variable.

I changed my layout to include all the individual variables. What I was hoping to accomplish is narrow everything down to 1 variable which would have been stash:content.
> 0 votes

---
Tags: stash, parse-order
---


# Question
Title: Search both channel fields and related entries fields
Let's say I have two channels, call them "primary" and "secondary". Channel `secondary` is referenced in channel `primary` as a relationship.

Now I want to search the entries of `secondary` based on fields from both channels.

So for example:

```
{exp:channel:entries channel="secondary" search:field1="foo" search:field2="foo" {related_entries}search:field1="foo"{/related_entries}}
// show entries from channel secondary with "foo" in field1 and field2, and field1 from channel primary
{/exp:channel:entries}

```

Obviously that's just pseudo code, but hopefully it illustrates my aim. Also note that I'm using EE 2.5.2, hence the old style tag pair.

I think I read that I would instead need to use reverse related entries, but I'm not sure how that would work. It seems like that would pose the same problem.

Any help would be appreciated.

# Answer
> 2 votes
I think Low Search might do what you want: http://gotolow.com/addons/low-search/docs/tags#form-tag-relationships

---
Tags: search, relationships, related-entries, reverse-related-entries
---


title: Solspace custom mini calendar

text:
# Question
Title: Solspace custom mini calendar
I've been going off of the custom mini calendar found at the bottom of the page here: http://www.solspace.com/docs/calendar/mini/

What I'm trying to do is get a complete mini month to show but right now, with the code below, I'm only receiving the week in which 'today' resides (refer to this picture: https://i.stack.imgur.com/OVZcs.png).

Here's the code that I'm using:

```
        <div class="columns four">
          {exp:calendar:cal}
            {!-- Custom mini calendar --}
            {display_each_month}
              <table>
                <thead>

                  {!-- Display Month and Prev/Next month nav --}
                  {!-- TODO: segment properly to new cal pages --}
                  <tr>
                    <th colspan="1">
                        <a id="prev_month" class="icon left" href="{path='calendar/mini'}/{prev_month format="%Y/%m"}/"><</a>
                    </th>
                    <th colspan="5" id="month_title">
                      <a href="{path='calendar/mini'}/{month format="%Y/%m"}/">{date format="%F %Y"}</a>
                    </th>
                    <th colspan="1">
                      <a id="next_month" class="icon right" href="{path='calendar/mini'}/{next_month format="%Y/%m"}/">></a>
                    </th>
                  </tr>

                  {!-- Display week day letter headding ( S M T W T F S ) --}
                  <tr>
                    {display_each_day_of_week}
                      <th>
                        {day_of_week_one}
                      </th>
                    {/display_each_day_of_week}
                  </tr>

                </thead>

                <tbody>
                  {display_each_week}
                  <tr>

                    {display_each_day}
                    <td>
                      {!-- as stated above, this is only showing the week for which the date today resides in --}
                      {day}
                    </td>
                    {/display_each_day}

                  </tr>
                  {/display_each_week}
                </tbody>

              </table>
            {/display_each_month}
          {/exp:calendar:cal}
        </div>

```

# Answer
Try adding these parameters:

```
date_range_start="year-month-01"
date_range_end="year-month-last"

```

Without them the cal tag will assume the start date is today.
> 1 votes

---
Tags: solspace, solspace-calendar, calendar
---


# Question
Title: Converting standard file field to an Assets field with a remote source
I have about 250 blog entries, each with a standard EE file field that points to a file on the same local server EE is running on. I've installed the Assets add-on and set up an external source (an Amazon S3 bucket). I converted that standard file field to an Assets field pointing at that S3 bucket and it's working beautifully!

When creating a new blog post the file uploads to S3 without a hitch. Now onto the old posts:

What I need to do is to tell the Assets field to look for the image on S3 and not in the local filepath. I can manually move those images into place on S3, but I don't know what to do on the EE side to update the DB so Assets knows where to look.

Suggestions?

# Answer
> 2 votes
All you have to do is move the files to S3 from within Assets’ File Manager itself. If you do that, all of your existing data will automatically start pointing to the new location on S3.

---
Tags: assets, file-uploads, database, s3, aws
---


# Question
Title: include_once from codeigniter in EE template
i'm finishing an EE website that contains a codeigniter intranet part. two setups, two databases. runs smooth. now i want to include some codeigniter php files into EE. was thinking to do so via php include, but now it seems that including codeigniter doesn't work for some reason.

i have this:

```
<?php
include_once './photogallery/index.php'; // works perfect
include_once './CodeigniterIntranet/photogallery/show'; // failed to open stream: No such file or directory
?>

```

any advice?

# Answer
Do you really have a php file named `./CodeigniterIntranet/photogallery/show` (without the `.php` extension)?
> 1 votes

---
Tags: codeigniter
---


title: Solspace Calendar occurrences

text:
# Question
Title: Solspace Calendar occurrences
I'm investigating a small issue on a site. I'm positive that my issue is just due to my inexperience with Solspace Calendar.

I'm using the calendar:occurrence tag to display an event list per category. It seems to only be showing events that are recurring events, rather than any single occurrence events.

This is the opening tag/code that I'm using:

```
{exp:calendar:occurrences
orderby="event_start_date"
sort="asc"
date_range_start="today"
date_range_end="6 months"
upcoming_occurrences_limit="1"
show_months="6"
limit="3"
dynamic="off"
search:event_ministry="{embed:entry_id}"}

```

Should I be using :calendar:events instead? We previously tried that but weren't able to get the repeating events to display.

Thanks for your help!

# Answer
> 1 votes
Yes, try using the events tag instead, inside which you can use {occurrences}.

---
Tags: solspace, calendar
---


# Question
Title: Why are the Wygwam toolbar icons not showing?
I am running Expression Engine 2.6.1 and Wygwam 3.0.2 but the icons do not show up in the field. I could use some help getting them to show up properly.

I get the following error when the page loads in Chrome:

```
chrome.tabs is not available: You do not have permission to access this API. Ensure that the required permission or manifest property is included in your manifest.json. [VM] binding (1054):216
Binding.generate [VM] binding (1054):216
(anonymous function) [VM] tabs (1140):43
(anonymous function) measureIt.js:120
Uncaught TypeError: Cannot call method 'create' of undefined measureIt.js:120
GET http://independence4seniors.com/themes/third_party/wygwam/lib/ckeditor/skins/wygwam3/skin.js?t=D09H5XK 404 (Not Found) ckeditor.js:16
Uncaught TypeError: Cannot read property 'init' of undefined

```

I reloaded the theme but still get the same result.

Any ideas?

Thanks.

# Answer
> 1 votes
Re-download WYGWAM and try it again. There's a missing or corrupt file in there.

If you use Channel Images, make sure you add the WYGWAM plugin to the Channel Images themes directory or you'll get a similar error.

# Answer
> 1 votes
For me this normally happens if I forget to upload the themes directory.

When you upgraded did you reinstall the Wygwam themes into your /themes/third-party directory?

---
Tags: wygwam
---


# Question
Title: SQL query to count question marks in comment field?
Wanted to ask if anyone can help me with (code or commands to use) an sql query to count how many times the question mark character appears in table \*exp\_comments\*, field *comment*?

Thanks! Lee

# Answer
> 3 votes
To get a total of all occurrences across all comments:

```
SELECT SUM(LENGTH(comment) - LENGTH(REPLACE(comment, '?', ''))) AS occurrences FROM exp_comments

```

To get the count for each comment in a query result:

```
SELECT LENGTH(comment) - LENGTH(REPLACE(comment, '?', '')) AS occurrences FROM exp_comments

```

(MySQL doesn't have a specific function for this, but I found this clever technique - which takes the field's character count and subtracts its count with all of your target character removed - here.)

---
Tags: mysql
---


title: Does {lang:x} work?

text:
# Question
Title: Does {lang:x} work?
The EllisLab documentation on search results includes an interesting code snippet:

```
<table border="0" cellpadding="6" cellspacing="1" width="100%">
    <tr>
        <th>{lang:title}</th>
        <th>{lang:excerpt}</th>
        <th>{lang:author}</th>
        <th>{lang:date}</th>
        <th>{lang:total_comments}</th>
        <th>{lang:recent_comments}</th>
    </tr>
 (...)

```

Source: http://ellislab.com/expressionengine/user-guide/modules/search/results.html

I'm trying to find documentation on how to use `{lang:...}` and where the values come from. Taking recent\_comments as an example, I'm not finding it in any of the lang files. My attempt to take one from the English core\_lang.php (`system_off_msg`) didn't work either.

Any thoughts? Was this just a placeholder in the documentation?

# Answer
These special variables are only used in the Member module and Search module on the front-end - they won't be parsed anywhere else. Why, I do not know.

To see what they correspond with, take a look at this snippet from the Search module code:

```
// Parse lang variables
        $swap = array(
            'lang:total_search_results' =>  lang('search_total_results'),
            'lang:search_engine'        =>  lang('search_engine'),
            'lang:search_results'       =>  lang('search_results'),
            'lang:search'               =>  lang('search'),
            'lang:title'                =>  lang('search_title'),
            'lang:channel'              =>  lang('search_channel'),
            'lang:excerpt'              =>  lang('search_excerpt'),
            'lang:author'               =>  lang('search_author'),
            'lang:date'                 =>  lang('search_date'),
            'lang:total_comments'       =>  lang('search_total_comments'),
            'lang:recent_comments'      =>  lang('search_recent_comment_date'),
            'lang:keywords'             =>  lang('search_keywords')
        );

```
> 1 votes

---
Tags: multi-language, multilingual, language
---


title: Solspace SuperSearch and URL Rewrites

text:
# Question
Title: Solspace SuperSearch and URL Rewrites
Can anyone help me with URL rewriting using Solspace SuperSearch as our SEO guys have suggested that these could be improved:

We have 5 dropdowns for make, model, fuel type, min price and max price. The form uses POST. Examples of the search results generated pages are:

**Blank Form** `http://www.motors.coop/search/results/search&cf_make=&cf_fuel=&cf_price-from=0&cf_price-to=50001/`

**Make Only** `http://www.motors.coop/search/results/search&cf_make=Audi&cf_model=&cf_fuel=&cf_price-from=0&cf_price-to=50001/`

**Diesel Only** `http://www.motors.coop/search/results/search&cf_make=&cf_fuel=Diesel&cf_price-from=0&cf_price-to=50001/`

Standard stuff, you'll agree. What our SEO company has suggested that these be re-written to something like this:

`http://www.motors.coop/search/bmw/diesel/5001/18000`

I agree that these are cleaner - is there a regex someone can suggest that can achieve this? The big issue is a user may not necessarily choose ***anything*** from ***any*** of the dropdowns. In this case, can the URL be something like:

`http://www.motors.coop/search/all/all/all/1/100000`

Hope someone can help. Thanks in advance.

# Answer
> 1 votes
Have a look at Template Routes by Rob Sanchez. You should be able to setup a route with wildcards in a set order, then match those to each part of the segment that Super Search needs. Something like:

```
$config['template_routes'] = array(
    'search/:any/:any/:any/:num/:num' =>
    'search/results/search&cf_make=$1&cf_model=$2&cf_fuel=$3&cf_price-from=$4&cf_price-to=$5'
);

```

The other thing you'd have to do is make your search form redirect to the clean URL, but that should be fairly easy.

---
Tags: search, url, solspace, supersearch, rewrite
---


title: forms (devdemon) and redirects

text:
# Question
Title: forms (devdemon) and redirects
I am redirecting a user to a custom template after they submit a form. I'd like to include their name on the thank you page, but as it's a redirect, I can't get any form data.

I tried editing this line on mod.forms.php

```
$form['return'] = $form['form_settings']['return_url'];

```

To

```
$form['return'] = '/mytmeplategroup/thankyou/' . ee()->input->post('name_first');

```

But as the return URL is generated BEFORE the form is submitted, this is clearly the wrong answer.

Can I pass custom variables to a new template (worst case, just a form submission entry Id and I can go get the data perhaps?)

# Answer
You can use use a variable in your return url like this:

return="/mytmeplategroup/thankyou/%FENTRY\_ID%/"

And on the thankyou template do something like this:

{exp:forms:entries fentry\_id="{segment\_3}"}
> 2 votes

# Answer
I dunno what Forms is doing with `return_url`, but could you do something with JavaScript in the generated form's `onsubmit` event?
> 1 votes

---
Tags: templates, forms, devdemon
---


# Question
Title: How can I check if a playa field is empty?
I have a playa field product\_videos and am using the following conditional to check if it is empty:

```
{if product_videos:total_children > 0}
  //do something
{/if}

```

This seems pretty straight forward to me, what am I missing?

I should add the result is that the code inside the conditional never appears despite there being entries.

I have also tried:

```
{if "{exp:playa:total_children field='product_videos'}"}
  //do something
{/if}

```

which is listed as a correct answer in this SO question, this results in a php error:

> A PHP Error was encountered Severity: User Warning
>
> Message: Invalid EE Conditional Variable: {if "exp:playa:total\_children entry\_id="285" field='product\_videos' var\_prefix="playaDbig9XJo"}
>
> Filename: libraries/Functions.php
>
> Line Number: 2855

# Answer
> 7 votes
...And as soon as I write it down in a question, I figured out my mistake.

Correct solution for future visitors was:

```
{if "{product_videos:total_children}" > 0}
  //do something
{/if}

```

---
Tags: playa, pixelandtonic, conditionals
---


# Question
Title: upload library not working in module I am building
I've been stuck trying to upload a file in a module I am buidling.

I've tried using the EE instance and now I am trying the CI instance.

I've checked permission settings and those are fine for the directory I am trying to upload to.

I set the form type to use the form\_open\_multipart

Here is my upload function that does not want to work:

```
function upload_file()
{
    $this->CI =& get_instance();

    $file = $this->EE->input->post('userfile');

    $config['upload_path'] = './images/';
    $config['allowed_types'] = 'gif|jpg|png';
    $this->CI->load->library('upload', $config);

    if ( ! $this->CI->upload->do_upload($file) )
        print 'could not upload file';
}

```

# Answer
> 2 votes
A few things that should help you out.

1) You should be using the EE instance. Normally you to the get\_instance() in the constructor of your module and make it available as a class variable.

2) The do\_upload method accepts a string with the name of the file upload field, not the value of the posted field.

Your code should look somehting like this

```
// Configure the upload class
$config['upload_path'] = './images/';
$config['allowed_types'] = 'gif|jpg|png';
$this->EE->load->library('upload', $config);

// Error checking
if ( ! $this->EE->upload->do_upload('file_field_name'))
{
    $data = array(
      'error' => $this->EE->upload->display_errors()
    );

}
// No problems so do our processing
else
{
    // Store the info about the uploaded file
    $upload_data = $this->EE->upload->data();
}

```

This was taken directly from a module I wrote that uploads files, so should work for you with some minor adjustments.

---
Tags: add-on-development, module, file-uploads, uploads
---


# Question
Title: AngularJS, Cartthrob multi_add_to_cart with options = Nothing adding
I am building a web app for a client. The gist of it is this...

Using Angular JS / Cartthrob / Stash to load all products. AngularJS to filter through. Cartthrob handling the cart side of things.

The resulting HTML all looks OK to me. I think something is not quite right with the multi-add\_to\_cart tag and the why I have coded it. I have tried a zillion different set ups to get it to work.

Currently, when I submit, I get a refresh, no errors, but nothing is adding to the cart and debug doesn't show anything. I think I am missing a trick with the add to cart tag. Can you see what I have done wrong?

Product loop:

```
{exp:cartthrob:multi_add_to_cart_form return="" show_errors="yes"}
    <div class="accordion" id="product_list">
        <div class="accordion-group" ng-repeat="prod in products | filter:query ">
            <div class="accordion-heading order_listing">
                <div class="row">
                    <div class="col-lg-2 image_container">
                        <img ng-src="{{prod.images_url}}" width="100px">
                    </div>
                    <div class="col-lg-7">
                        <h4>{{prod.series_description | uppercase}}: <small>{{prod.product_sku}}</small></h4>
                        <span ng-show="prod.sort_group !=''" class="label label-info">{{prod.sort_group}}</span>
                        <span ng-show="prod.tool_type !=''" class="label label-warning">{{prod.tool_type}}</span>
                        <span ng-show="prod.material !=''" class="label label-danger">{{prod.material}}</span>
                        <em class="text-muted">{{prod.finish}}</em>
                        <br><br>
                        <p class="text-muted">{{prod.application_details}}</p>
                    </div>

                    <div class="col-lg-1">
                        <i class="icon-heart icon-2x icon-grey pull-right"></i>
                    </div>

                    <div class="col-lg-2">
                        <a class="accordion-toggle pull-right btn btn-primary btn-mini" data-toggle="collapse" ng-click="getDetail($index)" data-parent="#product_list" href="#collapse{{prod.entry_id}}">
                            View Details
                        </a>
                    </div>
                </div>
            </div>
            <div id="collapse{{prod.entry_id}}" class="accordion-body collapse">
                <div class="accordion-inner">
                    <div class="panel">
                      <div class="panel-heading"><strong>Pack Details:</strong></div>
                      {{prod.pack_details}}
                    </div>
                    {sn:general:detailloader}
                    <table class="table table-hover">
                        <tr>
                            <th>Series Code</th>
                            <th>Size</th>
                            <th>Price</th>
                            <th>Add to order</th>
                        </tr>

                        <input type="text" name="entry_id[{{prod.entry_id}}]" value="{{prod.entry_id}}" style="width: 40px;" />
                        <input type="text" name="title[{{prod.entry_id}}]" value="{{prod.entry_id}}" style="width: 40px;" />

                        <tr ng-repeat="series_detail in productDetail">
                            <td>{{series_detail.part_no}}</td>
                            <td>{{series_detail.size}}</td>
                            <td>{{series_detail.price2020 | currency:"£"}}</td>
                            <td>
                                <div class="form-inline">
                                    <input class="form-control input-small" ng-model="qty" ng-init="qty=''" type="text"  name="quantity[{{prod.entry_id}}-{{$index}}]" style="width: 40px;">

                                    <input type="text" value="{{series_detail.part_no}}" name="item_options[{{prod.entry_id}}-{{$index}}][option_value]" style="width: 40px;"/>

                                    <input type="text" name="price[{{prod.entry_id}}-{{$index}}]" value="{{series_detail.price2020 * qty}}" style="width: 60px;" />
                                    <button type="submit" class="btn btn-default btn-small">Add</button>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    {/exp:cartthrob:multi_add_to_cart_form}

```

Thanks all

# Answer
Your rendered HTML would be far more useful than your template code in this case, but there are some irregularities here that I see:

```
<input type="text" name="entry_id[{{prod.entry_id}}]" value="{{prod.entry_id}}" style="width: 40px;" />
<input type="text" name="title[{{prod.entry_id}}]" value="{{prod.entry_id}}" style="width: 40px;" />

```

These indicate to me that you're using each product's `entry_id` as the key for your array of items. But later you have:

```
<input class="form-control input-small" ng-model="qty" ng-init="qty=''" type="text"  name="quantity[{{prod.entry_id}}-{{$index}}]" style="width: 40px;">
<input type="text" value="{{series_detail.part_no}}" name="item_options[{{prod.entry_id}}-{{$index}}][option_value]" style="width: 40px;"/>
<input type="text" name="price[{{prod.entry_id}}-{{$index}}]" value="{{series_detail.price2020 * qty}}" style="width: 60px;" />

```

Here you're using `entry_id-$index` as the key, so your `quantity`, `item_options` and `price` will not match your `entry_id` and `title`.

(By the way, I'm pretty sure that `title` is ignored when adding products which are not "on-the-fly", and that `allow_user_price` must be set and if you want to pass a custom `price` for the same.)
> 2 votes

---
Tags: cartthrob
---


# Question
Title: How can i show entries from two categories?
is there an easy way to show two EE categories in a list? let's say i have *agenda/C3* and *agenda/C9*

can i combine this to *agenda/C3&C9* (this obviously doesn't work)

(my problem: the C3 is a default category and should always be showed, even if you select another category)

cheers, dave

# Answer
> 2 votes
I just read the answer you posted answer and you don't need PHP to do this.

In the template where you have your `{exp:channel:categories}` tag, change how the category URL is created so it just passes the category ID...

`<a href="{path=agenda}">` becomes `<a href="/agenda/{category_id}">`.

This will give you a URL that looks like `/agenda/9`.

Then in your channel:entries tag you use `category="9|{segment_2}"`.

# Answer
> 4 votes
Have you tried category="" in your channel?

```
{exp:channel:entries channel="{channels}" category="3|9" dynamic="yes"  }

```

http://ellislab.com/expressionengine/user-guide/modules/channel/channel\_entries.html#category

You could also try low seg2cat http://gotolow.com/addons/low-seg2cat/docs

> ...where n is the segment number. {segment\_category\_ids} will return an inclusive stack of all found category ids, for example: 4&12. {segment\_category\_ids\_piped} will return an exclusive list: 4|12.

# Answer
> 0 votes
this is how i solved it

separate category template starting with

```
<?php
$uri = $_SERVER['REQUEST_URI'];
$pieces = explode("/", $uri);
$lastsegment = $pieces[4];
$catid = substr($lastsegment, 1);
?>

```

and then the tag

```
{exp:channel:entries channel="agenda" status="open" limit="50" category="9|<?php echo $catid ?>" orderby="entry_date" sort="asc" start_on="{current_time format='%Y-%m-%d 00:00'}" show_future_entries="yes"}

```

and php enabled on input, 9 is the category id that has to be showed by default

---
Tags: categories
---


# Question
Title: What is the best way to tag images for use in other channels?
Here is my scenario: I have over 1,000 untagged images that I need to be able to sort and search in order to use in my entries.

I am looking at tagger by DevDemon but then I can only look for one tag at a time in the "Content-\>Edit" page. (Unless I'm missing something).

What I'd like would be the ability to add multiple tags fairly easily (Or easy for me to make forms that will create/updates the entries). Plus the ability to then search for the images using more than one tag (so I want to look for images that are tagged with both "men" and "hard hat"). When I do that search, I'd like the results to show the image (or a thumbnail).

Do any of you know of anything out there that already does this? I will build it if I need to but just hate to reinvent the wheel.

thanks!

# Answer
> 2 votes
Take a look at Assets (http://devot-ee.com/add-ons/assets) by Pixel & Tonic. It allows to you add metadata for each image which you can use for "tagging".

---
Tags: search, sort
---


title: Removing SafeCracker & Inserted Assets

text:
# Question
Title: Removing SafeCracker & Inserted Assets
I'm trying to remove ALL inserted assets in SafeCracker, I've got my opening tag like so:

```
{exp:safecracker
    channel="{prv_channel}"
    return="{segment_1}/{segment_2}/{segment_3}"
    entry_id="{entry_id}"
    class="form-inline"
    include_jquery="no"
    include_assets="no"
    datepicker="no"
}

```

So in theory, should this remove all the "inserted" code? Well... It doesn't :(

```
<script type="text/javascript" charset="utf-8">
if (typeof EE == "undefined" || ! EE) {
var EE = {"BASE":"http:\/\/website\/index.php?","THEME_URL":"http:\/\/website\/themes\/cp_themes\/default\/","PATH_CP_GBL_IMG":"http:\/\/website\/themes\/cp_global_images\/","filebrowser":{"endpoint_url":"ACT=2","window_title":"File Manager","theme_url":"http:\/\/website\/themes\/cp_themes\/default\/"},"fileuploader":{"window_title":"File Upload","delete_url":"C=content_files&M=delete_files"},"lang":{"or":"or","resize_image":"Resize Image","return_to_publish":"Return to Publish","confirm_exit":"When you leave, any data entered will be lost. Are you sure you want to leave?","add_new_html_button":"Add New HTML button"},"publish":{"show_write_mode":true,"title_focus":true,"smileys":false},"user_id":1,"XID":"ac7721bdd8cfa9b80a37ce5b27f741bae5d7ec41"};}
mySettings = {"nameSpace":"html","onShiftEnter":{"keepDefault":false,"replaceWith":"<br \/>\n"},"onCtrlEnter":{"keepDefault":false,"openWith":"\n<p>","closeWith":"<\/p>\n"},"markupSet":[{"name":"b","key":"B","openWith":"<strong>","closeWith":"<\/strong>","className":"btn_b"},{"name":"i","key":"I","openWith":"<em>","closeWith":"<\/em>","className":"btn_i"},{"name":"blockquote","key":"Q","openWith":"<blockquote>","closeWith":"<\/blockquote>","className":"btn_blockquote"},{"name":"a","key":"A","openWith":"<a href=\"[![Link:!:http:\/\/]!]\"(!( title=\"[![Title]!]\")!)>","closeWith":"<\/a>","className":"btn_a"},{"name":"img","key":"","replaceWith":"","className":"btn_img"}]};
myWritemodeSettings = {"nameSpace":"html","onShiftEnter":{"keepDefault":false,"replaceWith":"<br \/>\n"},"onCtrlEnter":{"keepDefault":false,"openWith":"\n<p>","closeWith":"<\/p>\n"},"markupSet":[{"name":"b","key":"B","openWith":"<strong>","closeWith":"<\/strong>","className":"btn_b"},{"name":"i","key":"I","openWith":"<em>","closeWith":"<\/em>","className":"btn_i"},{"name":"blockquote","key":"Q","openWith":"<blockquote>","closeWith":"<\/blockquote>","className":"btn_blockquote"},{"name":"a","key":"A","openWith":"<a href=\"[![Link:!:http:\/\/]!]\"(!( title=\"[![Title]!]\")!)>","closeWith":"<\/a>","className":"btn_a"},{"name":"img","key":"","replaceWith":"","className":"btn_img"}],"onTab":{"keepDefault":false,"replaceWith":"\t"}};
</script>

<script type="text/javascript" charset="utf-8" src="http://website/index.php?ACT=58&ui=core,widget,mouse,position,draggable,resizable,button,dialog&plugin=scrollable,scrollable.navigator,markitup,thickbox,toolbox.expose,overlay,tmpl&v=1366647338"></script>

<script type="text/javascript" charset="utf-8">
// <![CDATA[
$(document).ready(function() {
    if (typeof SafeCracker == "undefined" || ! SafeCracker) { var SafeCracker = {markItUpFields:{}};}});
// ]]>
</script>

```

WHY!?

I can't remove them in the module file due to me needing them elsewhere on another template.

How can I remove these? Because jQuery isn't included before these scripts, it's just throwing big fat errors in console! Eugh.

# Answer
> 3 votes
You're likely looking at the new docs that just went up, for EE 2.7 (released yesterday).

Under EE 2.6.1, the parameter you want is called `safecracker_head`, not `include_assets`.

---
Tags: safecracker, jquery
---


# Question
Title: Using Expresso store in a responsive design
I'm looking for an ecommerce solution to use with EE but I need to be able to use it within a responsive design. I don't see anything in the docs as to what markup is output with a cart tag or checkout tag. From the "showcase" sites on the website, it looks like the cart is a table and the checkout is a simple form. Is this the case?

I've built a responsive ecommerce site using Foxycart before and had to override a lot of their CSS, but got it working. How much control does the developer have over the markup and styling of the cart, checkout and other basic templates or tags?

Is there a vanilla install somewhere out there to look at the code?

Thanks.

# Answer
> 6 votes
Store like ExpressionEngine does not make any assumptions about your template content. The checkout tag and product tags will create an opening and closing `<form>` tag but other then that you are free to arrange your template however you see fit. There are no predesignated styles or html elements that you need to use or create.

When you purchase Store there is a set of example templates that you can use but the actual html portion is completely up to you.

---
Tags: expresso-store
---


# Question
Title: Getting Recipient Names/email address in Notification
I have another FreeForm question. Below is my Freeform code that is now working, sending emails to different recipients based on the checkboxes selected.

Now I need those selections to appear in the notification email, so the recipients are aware of each other being contacted.

Nosing around it looks like I need a combination of a hidden field and some javascript? Does anyone happen to have that js handy they could post? I'm usually ok to tweak something that's close but don't know enough js to write from scratch.

```
 {exp:freeform:form
form:id="contact-form"
form_name="contact"
required="name|email|message|recipient_email"
return="contact/thanks"
recipients="yes"
recipients_limit="11"
recipient_template="to_era"
recipient1="name|email1@address.com"
recipient2="name|email2@address.com"
recipient3="name|email3@address.com"
recipient4="name|email4@address.com"
recipient5="name|email5@address.com"
recipient6="name|email6@address.com"
recipient6="name|email7@address.com"
recipient8="name|email8@address.com"
recipient9="name|email9@address.com"
recipient10-="name|email10@address.com"
recipient11="name|email11@address.com"
}

<p>
    <label for="name">Name:</label><br />
    <input type="text" id="name" name="name" size="40" maxlength="64" value="" class="textfield" />
  </p>

<p>
    <label for="email">Email:</label><br />
    <input type="text" id="email" name="email" size="40" maxlength="128" value="" class="textfield" />
  </p>

  <p>
    <label for="telephone">Telephone:</label><br />
    <input type="text" id="telephone" name="telephone" size="40" maxlength="16" value="" class="textfield" />
  </p>

  <p>
    <label for="availability">What is the best time for us to reach you?</label><br />
    <input type="text" id="availability" name="availability" size="40" value="" class="textfield" />
  </p>

  <p>
    <label for="message">Message:</label><br />
    <textarea id="message" name="message" rows="18" cols="40" class="textfield"></textarea>
  </p>

  <fieldset id="community_checkboxes">
      <legend>Select each of the communities are you interested in.</legend>

        <p> {!-- ravenna --}
           <input{if segment_2=="ravenna"} checked{/if} type="checkbox" id="{freeform:recipient_value1}" class="community_chbx" value="{freeform:recipient_value1}" name="recipient_email[]">
           <label for="{freeform:recipient_value1}">{freeform:recipient_name1}</label>
        </p>

        <p>
           <input{if segment_2=="wallingford"} checked{/if} type="checkbox" id="{freeform:recipient_value2}" class="community_chbx" value="{freeform:recipient_value2}" name="recipient_email[]">
           <label for="{freeform:recipient_value2}">{freeform:recipient_name2}</label>
        </p>

          <p> {!--lakeshore--}
           <input{if segment_2=="north-seattle"} checked{/if} type="checkbox" id="{freeform:recipient_value3}" class="community_chbx" value="{freeform:recipient_value3}" name="recipient_email[]">
           <label for="{freeform:recipient_value3}">{freeform:recipient_name3}</label>
        </p>

        <p> {!-- broadview --}
           <input{if segment_2=="mercer-island"} checked{/if} type="checkbox" id="{freeform:recipient_value4}" class="community_chbx" value="{freeform:recipient_value4}" name="recipient_email[]">
           <label for="{freeform:recipient_value4}">{freeform:recipient_name4}</label>
        </p>

        <p> {!--wallingford --}
           <input{if segment_2=="lakeshore"} checked{/if} type="checkbox" id="{freeform:recipient_value5}" class="community_chbx" value="{freeform:recipient_value5}" name="recipient_email[]">
           <label for="{freeform:recipient_value5}">{freeform:recipient_name5}</label>
        </p>

        <p> {!-- mercer-island --}
           <input{if segment_2=="issaquah"} checked{/if} type="checkbox" id="{freeform:recipient_value6}" class="community_chbx" value="{freeform:recipient_value6}" name="recipient_email[]">
           <label for="{freeform:recipient_value6}">{freeform:recipient_name6}</label>
        </p>

        <p> {!--issaquah --}
           <input{if segment_2=="broadview"} checked{/if} type="checkbox" id="{freeform:recipient_value7}" class="community_chbx" value="{freeform:recipient_value7}" name="recipient_email[]">
           <label for="{freeform:recipient_value7}">{freeform:recipient_name7}</label>
        </p>

        <p> {!--bellevue --}
           <input{if segment_2=="bellevue"} checked{/if} type="checkbox" id="{freeform:recipient_value8}" class="community_chbx" value="{freeform:recipient_value8}" name="recipient_email[]">
           <label for="{freeform:recipient_value8}">{freeform:recipient_name8}</label>
        </p>

    <p>
           <input type="checkbox" id="{freeform:recipient_value10}" class="community_chbx" value="{freeform:recipient_value10}" name="recipient_email[]">
           <label for="{freeform:recipient_value10}">{freeform:recipient_name10}</label>
        </p>

        <p>
           <input{if segment_2==""} checked{/if} type="checkbox" id="{freeform:recipient_value9}" class="community_chbx" value="{freeform:recipient_value9}" name="recipient_email[]">
           <label for="{freeform:recipient_value9}">{freeform:recipient_name9}</label>
        </p>

  </fieldset>

  <p><input id="button_submit" name="submit" type='submit' value='Submit Form' /></p>
{/exp:freeform:form}

```

# Answer
You could have a text field named 'chosen\_recipients and use a jQuery listener to wait for click of the checkboxes and concat the name results in the hidden field.

The hidden field could then be output as a normal field in the notification.

```
    <input name="chosen_recipients" type="hidden" />
    <script type="text/javascript">
            jQuery(function($){
                    var $chosenRecipients   = $('[name="chosen_recipients"]');
                    var $recipientChecks    = $('[name^="recipient_email"]');

                    $recipientChecks.click(function(){
                            //force this check to wait until checkbox state is resolved
                            //works weirdly in some browsers without this
                            setTimeout(function(){
                                    $chosenRecipients.val('');
                                    var newVal = [];
                                    $recipientChecks.each(function(){
                                            if ($(this).is(':checked'))
                                            {
                                                    newVal.push( $('label[for="' + $(this).attr('id') + '"]').text());
                                            }
                                    });
                                    $chosenRecipients.val(newVal.join(', '));
                            },0);
                    });
            });
    </script>

```
> 4 votes

---
Tags: solspace-freeform
---


title: segment_2 in a page URL giving 404

text:
# Question
Title: segment_2 in a page URL giving 404
Using the pages module, I have a number of entries that load at domain.com/url\_title, for example, domain.com/contact

```
    {exp:channel:entries channel="main" dynamic="on"
    disable="categories|member_data|pagination|trackbacks"
    limit="1" url_title="{segment_1}"}
        <h1>{title}</h1>
        {body}
    {/exp:channel:entries}

```

Pages display fine. The contact page has a FreeForm form that redirects to domain.com/contact/thank-you, but gives a 404 error. The pages URIs are set correctly. What gives?

# Answer
Adding an additional segment on to the end of a Pages URI will trigger a 404. I recommend using the **Freebie** extension to set an ignored segment, in your case "thank-you." This will allow you to redirect to `/contact/thank-you` and show the contact page while still using the second segment for any conditionals.

```
{if freebie_2 == "thank-you"}
    <p>Your thank you message here.</p>
{/if}

```
> 2 votes

# Answer
When using the Pages module, the URL Title is not used and should not be fed to to the `{exp:channel:entries}` tag. If you remove that parameter from the tag and change `dynamic="yes"` or remove the dynamic parameter altogether, it will pick up the correct page entry automatically.

You'll also need to make sure the entry with the Page URI set has the correct template configured on the Pages tab.
> 4 votes

---
Tags: solspace-freeform, 404, pages
---


# Question
Title: Site uses switchee to serve index or 'static' page; Now getting unexpected 404s
My site's index page template uses switchee to determine whether to serve up index (home) page or a "single page" entry from the static channel.

I'm attempting to set up a 404 page for the site, and created a 404 template in the default site template group.

Once I set up 404s, all the "static" entries display as 404 instead.

I'd like to keep the option of single pages at the segment\_1 level, so the site can add other single-purpose landing pages over time.

My Global Template Preferences:

* Enable Strict URLs Yes, No, *(this setting makes no difference)*
* 404 Page: site/404 *(when set to None, things display okay)*

Index template contains the following:

```
{exp:switchee variable="{segment_1}" parse="inward"}

{!-- ----- HOME PAGE ----- --}
{case value="index|''"}
       ...
{/case}

{!-- ----- Static Pages + Sidebar Asides ------ --}
    {case default="Yes"}

     {exp:channel:entries
        channel="static"
        limit="1"
        dynamic="no"
        disable="categories"
        require_entry="yes"
        url_title="{segment_1}"
        }

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

        ...
   {/exp:channel:entries}
    {/case}

{/exp:switchee}

```

**EDIT NOTE (and apology):** When I first posted this, I inadvertantly pasted the {if switchee\_no\_results} outside the {exp:channel:entries} tag pair. But it was inside that tag pair in my actual code. So sorry to have misled you. It was not my intention.

(the if switchee\_no\_results, require\_entry, url\_title="{segment\_1}" were all recently added while trying to get things working with 404s)

Here is Template Debugging for the about page (an entry in the static channel)

When **Global Template Preferences** are set to strict=No and **404 Page=None**:

(0.000006 / 4.56MB) - Begin Template Processing -
(0.000940 / 4.60MB) URI: about
(0.000952 / 4.60MB) Path.php Template: /
(0.000963 / 4.60MB) Retrieving Template
(0.000972 / 4.60MB) Parsing Template URI
(0.005528 / 4.80MB) Showing index. Template not found: about
(0.005556 / 4.81MB) Retrieving Template from Database: site/index
(0.006652 / 4.81MB) Template Found
(0.007026 / 4.82MB) Retrieving Template from File

When **Global Template Preferences** changed to 404 **Page=site/404**

(0.000005 / 4.56MB) - Begin Template Processing -
(0.000966 / 4.60MB) URI: about
(0.000978 / 4.60MB) Path.php Template: /
(0.000989 / 4.60MB) Retrieving Template
(0.000998 / 4.60MB) Parsing Template URI
(0.005462 / 4.80MB) Template group and template not found, showing 404 page

Other things I have tried (which have not made any difference):

```
{case value="{segment_1}" default="yes"}

```

Based on James Smith's URL schematic which he mentions here on EESE (topic: strict urls), I fear I broke some cardinal rule about segment\_1. I hope not.

Are you aware of any way I can keep the basic setup as described (a single, index template uses switchee to serve up both home page and single entries in the static channel) and make the 404s work right?

**UPDATED:** I took this conversation to the switchee support forum on devotee, and based on Mark Croxton's response, I implemented a fix and describe it below.

# Answer
The answer is: Don't use switchee on the site/index template if using a 404 template.

My solution, Long Story Short:

1. Use Pages for all segment-1-style one-off static pages.
2. Break up the original template into two templates.

---

The kernel of the answer was in my statement:

> Based on James Smith's URL schematic which he mentions here on EESE (topic: strict urls), I fear I broke some cardinal rule about segment\_1. I hope not.

Well, I did break the cardinal rule.

I took up the matter in the devotee switchee forum, and after I provided more template debugging reports, Mark Croxton referred to the James Smith schematic, and said:

> \[Mark Croxton:\] To use static pages in segment\_1 requires the Pages or Structure modules. Alternatively you could use an htaccess rule or one if the new routing add-ons to create custom routes for static pages.

---

Gory Fix Details, or, How I implemented Pages
*(I know, I know. I have not used Pages much.)*

I removed switchee entirely from this site/index template. Breakdown of what I did with what was in each case statement.

```
{!-- ----- HOME PAGE ----- --}
{case value="index|''"}
   ...
{/case}

```

Everything *inside* case value="index|&c" remained in the site/index template. (I'm showing the case statements here to refer back to the other template code posted in the original Q and other replies)

I created a second template, site/static. Everything *inside* the case (below) went there.

```
{!-- ----- Static Pages + Sidebar Asides ------ --}
{case default="Yes"}
{exp:channel:entries channel="static"  ..etc... }
...
{/exp:channel:entries}
{/case}

```

In Pages Module configuration, I set the Default Template for the Static channel to site/static. Then I went and changed all the entries in the static channel to Pages, and gave them their custom URLs.

Fixed.
> 1 votes

# Answer
I might try the following:

```
{exp:switchee variable="{segment_1}" parse="inward"}

{!-- ----- HOME PAGE ----- --}
{case value="index|"}
   ...
{/case}

{!-- ----- Static Pages + Sidebar Asides ------ --}
{case default="Yes"}

 {exp:channel:entries
    channel="static"
    limit="1"
    dynamic="no"
    disable="categories"
    require_entry="yes"
    url_title="{segment_1}"
    }

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

    ...

 {/exp:channel:entries}

{/case}

{/exp:switchee}

```

Subtle differences - note that the first switch case looks for a value of "index|" instead of index|'' and the if no results is placed within the entries loop in the default case (I'm not aware of an if switch\_no\_results, though it may exist - but in reality, setting a default case with no value to match is in effect the if else conditional).
> 0 votes

---
Tags: url, 404, segments, switchee
---


title: ExpressionEngine 1.6 x Nginx

text:
# Question
Title: ExpressionEngine 1.6 x Nginx
So Im sticking with EE1 but I wanted to know if anyone has updated or has any information on updating EE1 to nginx from apache?

Thanks

# Answer
> 2 votes
The Nginx page for ExpressionEngine has sample configs, that should work for EE 1.6.x. And, here are more examples in an Archived EE Forum Thread on Nginx. And, more good info is available in this Current EE Forum Thread on Nginx.

I think that any info you find on the web about using Nginx with EE should be applicable to EE 1, even if the example uses EE 2. From the point of view of the web server (Apache or Nginx), there aren't any significant differences between EE 1 and EE 2. In both EE 1 & 2, you need to redirect all requests to the index.php file, except for requests to actual files and folders.

---
Tags: ee1, server, nginx
---


title: DB error after Matrix update

text:
# Question
Title: DB error after Matrix update
Have just updated **Matrix to 2.5.6**.

When I go to **Add-ons \> Fieldtypes \> Matrix** to trigger the update script I get this error.

> A Database Error Occurred Error Number: 1060
>
> Duplicate column name 'var\_id'
>
> ALTER TABLE exp\_matrix\_cols ADD var\_id INT(6) UNSIGNED AFTER field\_id, ADD INDEX (var\_id)
>
> Filename: third\_party/matrix/ft.matrix.php
>
> Line Number: 496

# Answer
Take a look at the columns in exp\_matrix\_data table in the database.

* Does it have a field var\_id? If no, then the version you should set is 2.2.
* If yes, does it have a field is\_draft? If no, then the version you should set is 2.3
* If yes, then the version you should set is 2.5.6

Now, set the version number we determined in the previous three steps for the Matrix field in the exp\_fieldtypes table and go visit the Add-ons -\> Fieldtypes -\> Matrix page and hit submit.

Everything should be all working now.
> 4 votes

---
Tags: matrix, pixelandtonic
---


# Question
Title: Removing index.php with add-on domain - CP urls break
I have EE Core installed in a subdirectory of my site, but it is set up as an add-on domain.

I followed the official instructions to remove index.php and the urls work if I type them manually (without index.php), but all the links generated from the CP break:

View Site link displays like this: http://domain.me/?URL=http://domain.me/

View Template displays: http://domain.me/?URL=http://domain.me/services and doesn't rewrite.

However, if I type in domain.me/services, the rewrite works. I can see that it's stripping the "services" segment, but I don't know why.

This is the only thing in my .htaccess:

```
# Removes index.php from ExpressionEngine URLs

RewriteEngine On

RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

```

Any help would be greatly appreciated!

# Answer
> 0 votes
Try adding these lines at the end of your .htaccess

```
RewriteCond %{QUERY_STRING} ^(ACT=.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} ^(URL=.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} ^(CSS=.*)$ [NC]
RewriteRule ^(.*)$ /index.php\?&%{QUERY_STRING} [L]

```

---
Tags: control-panel, url, htaccess, subdomain, rewrite
---


# Question
Title: A standard global variable in the params for a module is not being parsed
I have a module tag with a param that accepts a string.

```
{exp:test:foo return_url="{current_url}"}
...
{/exp:test:foo}

```

In the module method, I get the return\_url param using

```
$return_url      = $this->EE->TMPL->fetch_param('return_url');

```

The problem is that I get the literal string

`{current_url}`

As opposed to it being parsed and getting the current url.

Is there a way to solve this? or is this a parse order issue?

# Answer
The issue is parse order. Read the attached pdf.parse order. Turn on the debugger and then view the template in your browser. Scroll down thru the debugger until you find the tag containing {current\_url}. You will see that that {current\_url} has not been parsed. According to the attached doc, it is not parsed until step 9 - last.

In your module, try

`$uri_string = $this->EE->input->server('PATH_INFO') !== FALSE ? $this->EE->input->server('PATH_INFO') : '/'.$this->EE->uri->uri_string();`

or

`$segments = array_values($this->EE->uri->segment_array());`

or

`$this->EE->functions->fetch_current_uri()`
> 4 votes

---
Tags: module, global-variables, parameters
---


# Question
Title: SQL select query almost works, except for the ORDER BY
I've got a query that very nearly works, except for the ORDER BY part.

In Plain English, I'm selecting the author\_ids for authors who've posted entries to a particular channel, and limiting it by a few member groups.

(why is this a query? Will use this as basis to list entries in channel by member, limiting the number of entries/author to 4)

So far, so good. This Query works:

```
 {exp:query sql="SELECT DISTINCT author_id
    FROM exp_channel_titles
    JOIN exp_members ON exp_channel_titles.author_id = exp_members.member_id
    WHERE exp_channel_titles.channel_id='5'
    AND exp_channel_titles.status = 'open'
    AND (exp_members.group_id = '5' OR exp_members.group_id = '6' OR exp_members.group_id = '7' OR exp_members.group_id = '8')"}

```

It works, but the listing needs to be ordered differently. I want to order them alphabetically by member last name.

Am using Profile:Edit and have custom channel fields for member\_first\_name and member\_last\_name (field\_id\_50)

I need to refer to exp\_channel\_titles twice. Here's a graphic representation of what info I'm referring to in the database:

```
 ct  exp_channel_titles             exp_members
     ==================             ===========
     author_id                      member_id
     status = open                  group_id = 5|6|7|8
     channel_id = 5

 ct2 exp_channel_titles             exp_channel_data
     ==================             ================
     entry_id                       entry_id
     channel_id = 12                field_id_50
     author_id

```

Here's my second query. It doesn't throw errors (um, yay?), but it does not change the order of the results, either.

```
SELECT DISTINCT ct.author_id
FROM exp_channel_titles AS ct
JOIN exp_channel_titles AS ct2 ON ct.author_id = ct2.author_id
JOIN exp_members ON ct.author_id = exp_members.member_id
JOIN exp_channel_data ON exp_channel_data.entry_id = ct2.author_id
WHERE ct.channel_id = 5
AND ct.status = 'open'
AND ct2.channel_id = 12
AND (exp_members.group_id = 5 OR exp_members.group_id = 6 OR exp_members.group_id = 7 OR exp_members.group_id = 8)
ORDER BY exp_channel_data.field_id_50 ASC

```

changing the first line does not produces an empty column of results for last name SELECT DISTINCT ct.author\_id, exp\_channel\_data.field\_id\_50 FROM etc.

How do I get my ORDER BY to work?

# Answer
> 1 votes
For a start, this line is incorrect...Entry\_id \<\> author\_id

`JOIN exp_channel_data ON exp_channel_data.entry_id = ct2.author_id`

Take your query and paste it into the inbuilt query form. Remove or add query lines one by one and test your query output until you get what you want.

---
Tags: query
---


# Question
Title: Why is my module not showing in the add-ons list?
I am building a simple little module, based on this tutorial;

http://ee-recipes.com/articles/details/our-first-module-part-2-setting-up-the-file-structure

I have called my module 'DownloadLogs' I have created the upd.downloadlogs.php, mcp.downloadlogs.php and mod.downloadlogs.php files, and also a lang.downloadlogs.php file.

I have put them all in /system/expressionengine/third\_party/downloadlogs and uploaded to my server. But I can't see them in the list of installable add-ons. I have also cleared all of the caches and logged out and in again as superadmin.

Have I missed anything? What does EE require to pick up my code as an available module?

# Answer
> 5 votes
Good on you for writing your first plugin. Use this as a starting point for your plugins, quick, easy and avoids missing something. pkg.io Create it, download, unzip and upload to third party folder, just like any other add on. Once you can 'see' it in the plugin/module list you're all set to add your code.

---
Tags: ee2, module
---