# Question
Title: How to display article alphabetically in expression engine?
we want to sort article entries by alphabetically in expressionengine so please guide me how to display entries by alphabetically. Thank you.

# Answer
> 4 votes
If all you want is to sort the entries, not to filter them by their initials, use `orderby="title"` and `sort` parameter:

```
{exp:channel:entries channel="news" limit="10" orderby="title" sort="asc"}
    [...}
{/exp:channel:entries}

```

# Answer
> 1 votes
You can use Low Alphabet for it.

---
Tags: ee2
---


# Question
Title: How i can display article filter by age in ee2?
I am displaying age range by using following code.

```
{exp:channel:entries channel="article" search:age="1-20|21-40|41-60|61-80|81-100" limit="3" dynamic="off" sort="desc"}
<ul>
    <li><a href="#">{age}</a></li>
</ul>
{/exp:channel:entries}

```

so according to above code i am getting following result

```
<a href="#">41-60</a>
<a href="#">1-20</a>
<a href="#">21-40</a>

```

now i want to get all article of age range ="41-60" as result when i click on range 41-60 how can i get this result ?

i am useing following sturcture for article entry

# Answer
I'm not sure I fully understand your question (you might want to try to clarify it a little).

```
{exp:channel:entries channel="article" search:age="41-60" limit="3" dynamic="off" sort="desc"}

```

If you need to pass the search parameter dynamically then you could use URL segments. So your url might be something like

http://mysite.com/articles/age/41-60

Then your channel entries tags would be

```
{exp:channel:entries channel="article" search:age="{segment_3}" limit="3" dynamic="off" sort="desc"}

```

You *might* even be able to do something like

```
{exp:channel:entries channel="article" search:{segment_2}="{segment_3}" limit="3" dynamic="off" sort="desc"}

```

You might also want to look at using a search add-on such as Super Search or Low Search as they will allow you to search on ranges rather than fixed strings. (I think EE2.7 may allow you to search ranges also).
> 1 votes

---
Tags: ee2, search
---


title: removing index.php causes css to break

text:
# Question
Title: removing index.php causes css to break
I am trying to use the recommended htaccess file to remove the index.php.

but when I clear the Name of your site's index page in admin prefs the css will not load but everything else will on the templates.

my css: `<link href="{stylesheet=global_embeds/site_css}" type="text/css" rel="stylesheet" media="screen" />`

viewing source it appears fine: `<link href="http://domain.com/?css=global_embeds/site_css.v.1379946470" type="text/css" rel="stylesheet" media="screen" />`

```
<IfModule mod_rewrite.c>
        RewriteEngine On

        # Removes index.php from ExpressionEngine URLs
        RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

```

CSS is a css template in EE

# Answer
> 2 votes
Try this in your .htaccess:

```
RewriteCond %{QUERY_STRING} ^(css=.*)$ [NC]
RewriteCond %{QUERY_STRING} !^(ACT=.*)$ [NC]
RewriteRule ^(.*)$ /index.php?/%1 [L]

```

Before your main index rewrite.

Also if it's a physical file, ensure you have this in your htaccess:

```
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

```

Before the index rewrite rule.

So your htaccess may look something like this:

```
RewriteCond %{QUERY_STRING} ^(css=.*)$ [NC]
RewriteRule ^(.*)$ /index.php?/%1 [L]
RewriteCond $1 !^(images|admin|themes|robots\.txt|index\.php) [NC]
RewriteCond %{QUERY_STRING} !^(ACT=.*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

```

I'm guessing your CSS is a template in "global\_embeds" template group...? If so, keep it simple and change your html code as follows:

```
<link href="/global_embeds/site_css" type="text/css" rel="stylesheet" media="screen" />

```

---
Tags: htaccess, css
---


title: using query strings on EE1 site

text:
# Question
Title: using query strings on EE1 site
I see from another question that it's possible to pass query strings through the URL in EE1 but the question itself and its answer didn't really answer how this is done or help solve my specific question which is, can I pass a query string through the URL and have it fill out a form in EE1? I know you can do this easily with PHP and for this case I'm OK with enabling PHP on this single template. However, my quick test didn't seem to work. I added the following php to the head of the template:

```
<?php
$first_name = $_GET['first_name'];
$last_name = $_GET['last_name'];
?>

```

and added the following value parameter to the appropriate input fields:

```
value="<?php echo $first_name; ?>"
value="<?php echo $last_name; ?>"

```

I've tried setting PHP to render on input and output and have tried an embedded template for the form as well as placing it in the template but the query string values aren't populating the form fields.

What am I missing here? Is it even possible to get query strings to populate a form in EE1?

# Answer
Like @PonderTheWeb I don't see anything wrong with the code you've posted.

Can you confirm that you have PHP on in the template by doing a simple:

```
<? echo "hello world"; ?>

```

But much more importantly:

### Don't trust user input!

It is not good security practice to simply pass forward your $\_GET variables without sanitizing them first.

Fortunately EE makes this pretty easy for you.

```
// Load EE's Global Input Class
global $IN;

// Pass the EE Global inputs forward to the variable you want to use.
$first_name = $IN->GBL('first_name');
$last_name = $IN->GBL('last_name');

```
> 1 votes

---
Tags: forms, ee1, querystring
---


title: Relocating MSM templates

text:
# Question
Title: Relocating MSM templates
Is it possible to set the template location (when using template files) to refer to a location outside of the system folder?

For example, imagine we have two sites with a shared root, site A and site B:

```
/public_html/site_a/
/public_html/site_b/

```

If the primary/default site is site A is it possible to have the templates for site b situated within the site B folder, rather than within the default system folder.

Cheers,

Cole

# Answer
In addition to @Bhashkar's answer you can also set in your config file (/system/expressionengine/config/config.php):

> $config\['tmpl\_file\_basepath'\] = "/home/account/public\_html/templates/";

But I'd highly recommend placing above web root to maximise security: http://ellislab.com/expressionengine/user-guide/installation/best\_practices.html

Typically this could be your setup:

(/home/account being your server account root)

* /home/account/public\_html
* /home/account/system
* /home/account/add-ons
* /home/account/templates

Whereas a non-MSM site would utilise "default\_site" folder off of the templates folder, for a MSM enabled site, each site name (short name) would appear as folders inside the templates folder. As mentioned in the EE link above, you have to modify your index.php and admin.php to utilise the above web root path.

"system" folder would be the EE system folder (without the templates or third\_party folders.

"add-ons" being your third\_party folders (modules/extensions/plugins)

> $config\['third\_party\_path'\] = '/home/account/add-ons/';

I'd also suggest you avoid an MSM setup where you have one site within another, e.g.

> /home/account/public\_html/domain2

...which can lead to issues with rewrites and www.domain1.com/domain2 urls accessible. A neater more secure setup would be:

* /home/account/public\_html
* /home/account/domain2/public\_html
* /home/account/domain3/public\_html

or

* /home/account/public\_html
* /home/account/domains/domain2/public\_html
* /home/account/domains/domain3/public\_html

Apologies expanded from your original question...!
> 2 votes

# Answer
Yes its possible. If you set the Save Templates as Files as Yes under Global Template Preferences, you can see the templates are being saved as file within "system/expressionengine/templates/" \[default EE setting\] like: \[site\_short\_name\]/\[template\_group\_name\].group/templates

So for your purpose, the "Server path to site's templates" to be provided as "/public\_html/" and just created 2 another directories named with sites short name. Although, it would be done by EE itself. You need to only update "Server path to site's templates" under "Global Template Preferences".
> 1 votes

# Answer
You can also fixate your embedding templates with {embed="site\_a:\_inc/\_header"} and that will tell EE where to find your templates. This way you can share all of your templates across multiple sites without having to update those templates individually.
> 1 votes

---
Tags: templates, multi-site-manager
---


# Question
Title: PHP Fatal error: Allowed memory exausted
i ran into an HTTP Error 500(internal server error) when i tried to edit one of my page. it was working fine up until last week. i tried to to increased the Memory limit in to 256M, didn't help.

my error log says this: "PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 43504 bytes) in \*path/to/my/websit"/system/extensions/fieldtypes/ngen\_file\_field/ft.ngen\_file\_field.php on line 1074"

# Answer
> 1 votes
Usually this happens when a large image has been uploaded and ngen\_file\_field attempts to resize it and promptly runs out of memory.

This can be a particular problem with high DPI images - 300DPi print images are usually a culprit or simply very large over-sized images 2000+ pixels wide for example.

Take a look at recent images uploaded via FTP and see if you can spot any large images, download them and scale them appropriately before re-uploading them and it should clear the issue.

# Answer
> 1 votes
Increasing your PHP memory should be a last resort and is pretty much NEVER advisable. Judging from your error it looks like an upload FT is using really poor practices for handling the files you're managing (there is rarely a reason to open an entire file into PHPs memory like that).

Were it me, I'd look into either moving away from that specific add-on to something that handles files with a little more care or creating a special case for that specific entry/file.

That said, 256MB of memory is just insane. Really, that's a lot of memory to allow PHP to use so you may see some really negative side effects.

# Answer
> -1 votes
It looks like it needs more then 256M did you try to increase it to 512M? Be aware that not all servers allow htaccess to increase the memory limit.

```
php_value memory_limit 512M

```

---
Tags: php-errors
---


title: I can't track website visitors

text:
# Question
Title: I can't track website visitors
I'm new in EE, I was wondering is there anyway I can track the visitors that enter to my EE website?

Where do I click-on to see the # website visitors?

Please help me :)

# Answer
Google Analytics?

You can track individual views to entries by using the track\_views parameter in your Channel Entries tag, so this could be mapped to individual pages.

Or possibly your hosting has tracking built in...?
> 2 votes

# Answer
In addition to track-views functionality for individual channel entries, there's also the referrers module and template, but what it shows you is kind of limited (who landed on which page coming from where, using what IP and user-agent, basically.) More on that referrer module, and its template, in the documentation.

(I would use the referrer template as a quick-check, but DEFINITELY back it up with something far more thorough like Google Analytics.)

Edit: there's also a way to display the number of total hits and unique visitors. That's the stats module.
> 2 votes

---
Tags: ee2
---


# Question
Title: Assets + Low Variables // Limiting and Ordering By "Random"
Trying to do something I feel should be very simple to execute, but I cannot for the life of me seem to get it to work.

Here's my template snippet:

```
{exp:low_variables:parse var="lv_home_featured_images" limit="1" orderby="random"}
{exp:ce_img:single src="{url}" height="500" width="1200" crop="yes" attributes="style='width:1200px;height:500px;' alt='ALT'"}
{/exp:low_variables:parse}

```

I've got two images loaded into a Low Variable which has a fieldtype set to Assets.

Instead of getting just one random image selected, the same image keeps coming up over and over.

Running EE 2.7.0, Low Vars 2.3.5 and Assets 2.1.4. Any insight would be appreciated.

Thanks! ~ Wes

# Answer
Check out low's random addon - FREE. http://gotolow.com/addons/low-random/docs
> 1 votes

---
Tags: assets, low-variables
---


# Question
Title: How to make home page redirect to 404 error page when query string is added to URL
A client has put their website through some QA testing, and one of the items of feedback is that the home page of the site doesn't generate a 404 error when a query string is added to the home page URL, e.g. http://mywebsite.com/?dfdfdfd=dfdfdfd&dfdfdfd This only seems to affect the home page.

Is it possible to make a URL like this go to a 404 page, instead of loading the home page? If so, how?

I hoped to use the redirect tag and to redirect the home page to a 404 page if segment\_1 wasn't blank, but that doesn't work as EE doesn't seem to see the query string with segment conditionals (as expected).

I'm using strict URLs and have my 404 page setup correctly. Going to http://mywebsite.com/anythingsdfdd generates a 404 as expected. So it's just the query string URLs on the home page that I'm having issues with. Thanks in advance for any help.

# Answer
> 4 votes
**If you are using EE 2.7+** there is a new `current_query_string` global variable you can test against.

```
{if current_query_string}
    {redirect="404"}
{/if}

```

**Or, for versions less than EE 2.7**...

Install the Mo Variables Extension and enable the setting that gives you a `{query_string}` variable.

Then in your homepage template you can do

```
{if query_string}
    {redirect="404"}
{/if}

```

---
Tags: error, 404, querystring
---


title: Populate a playa hidden input field

text:
# Question
Title: Populate a playa hidden input field
How must I populate a playa hidden input field (in a safecracker form) with multiple entries? I tried passing the entry IDs separated by comma, semicolon, bar, but nothing seems to work. Only the first entry in the array gets saved. How do I have to format the entry IDs for multiple relationships to be saved?

Update: Thanks to Jeremy I now know how to add data to Playa correctly. Alas, it's still not working, now I get PHP errors.

This is what I have (inside a safecracker form): {exp:channel:entries channel="channel-name" category="{category\_id}" dynamic="no" disable="member\_data|pagination"}

- {title}{if {embed:parent\_id} == '{exp:playa:parent\_ids}' } {if:else} {/if}
{/exp:channel:entries}

I make a list with checkboxes. The conditionals check whether this entry is related to the entry currently being edited. So when it's related

```
<input class="relate" type="hidden" name="playa_field[selections][]" value="{entry_id}"/>

```

gets displayed, when it's not related

```
<input class="relate" type="hidden" name="0" value="{entry_id}"/>{/if}</label>

```

gets displayed. This works fine.

In the footer I load jQuery and this code to look for changes on checkboxes. When a checkbox is changed the "name" attribute gets updated.

```
    $(document).ready(function() {
        var $checkboxes = jQuery("#tag_list").find(":checkbox");
        $checkboxes.on('change', function () {
            var $relate = jQuery(this).siblings('.relate').attr("name"),
            $name = "playa_field[selections][]";
            if ($relate == $name) {
                jQuery(this).siblings('.relate').attr( "name", "0" );
            }
            if ($relate != $name) {
                jQuery(this).siblings('.relate').attr( "name", "playa_field[selections][]" );
            }
        });
    });

```

This also seems to work, I can see the "name" attribute get changed in the Safari developer tools.

But now, when I submit the field I get a bunch of the following PHP errors:

```
Severity: Warning

Message: array_filter() expects parameter 1 to be array, string given

Filename: playa/ft.playa.php

Line Number: 2356

Severity: Warning

Message: array_merge() [function.array-merge]: Argument #1 is not an array

Filename: playa/ft.playa.php

Line Number: 2356

```

What am I doing wrong?

# Answer
You'll want to actually use multiple hidden fields, each adding to an array:

```
<input type="hidden" name="cf_playa_field[selections][]" value="123">
<input type="hidden" name="cf_playa_field[selections][]" value="456">

```

You could also potentially write an extension to rework the POST data if you absolutely must submit the values in one field.
> 2 votes

# Answer
OK, I got this squared away. It seems like my name="0" inputs were causing the errors. Now I remove the complete hidden input when a checkbox is unchecked and create a new one on the fly when a checkbox is checked.
> 1 votes

---
Tags: safecracker, playa, channel-form
---


# Question
Title: Zoo Visitor update_form to update only some entries wipes out all other data
I've got a Zoo Visitor update\_form which i want to use to only update some of the fields in the zoo member channel.

But when i submit that form, it updates the fields in the tag, but wipes out the info of all other fields!

Any way round this? I don't really want to include all other custom fields as hidden fields!

Thanks!

# Answer
> 0 votes
Apparently it is a bug that only effects native EE relationship fields. Marvellous..

---
Tags: zoo-visitor
---


# Question
Title: Displaying a Wygwam field in a SAEF/Channel_Form entry
I finally have a project to use SAEF/Channel Forms in and I am banging my head against the wall trying to display the wygwam fields. Does anyone know the trick here?

# Answer
You should just need to type `{field:wygwam_field_name}` within the `{exp:channel:form}` tag pair.
> 1 votes

# Answer
I couldn't add all this in a comment:

Thanks Brandon. I see in the console that the field is attempting to populate, but I have the following errors in the console log:

Resource interpreted as Script but transferred with MIME type text/html: "http://itnqa.com/docs/config.js?t=D7GG". Uncaught SyntaxError: Unexpected token \< config.js:1 Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://itnqa.com/docs/skins/wygwam3/editor.css?t=D7GG". Resource interpreted as Script but transferred with MIME type text/html: "http://itnqa.com/docs/lang/en.js?t=D7GG". Uncaught SyntaxError: Unexpected token \< en.js:1 Resource interpreted as Script but transferred with MIME type text/html: "http://itnqa.com/docs/styles.js?t=D7GG". Uncaught SyntaxError: Unexpected token \< styles.js:1 Resource interpreted as Script but transferred with MIME type text/html: "http://itnqa.com/docs/plugins/stylesheetparser/plugin.js?t=D7GG". Uncaught SyntaxError: Unexpected token \< plugin.js:1 Uncaught TypeError: Cannot read property 'icons' of null

*** ADDING CODE *** I am using the following to open a colorBox popup to host the edit template:

```
{if logged_in}
    <div class="gallery">
        <a class="button green" href="{site_url}includes/edit/{url_title}" title="Editing ITN# {title}"><i class="icon-pencil"></i>  Click to Edit</a>
    </div>
{/if}

```

Then in my template for edit, I have this:

```
{exp:channel:form
    channel="doc"
    id="publishForm"
    return="docs/{last_segment}"
    url_title="{last_segment}"
}
    <label for="title">ITN Number</label>
    <input type="text" name="title" id="title" value="{title}" size="50" maxlength="100" onKeyUp="liveUrlTitle();">

    <input type="text" name="url_title" id="url_title" value="{url_title}" maxlength="75" size="50" style="display: none;">

    <label for="itn_title">ITN Title</label>
    <input type="text" name="itn_title" id="itn_title" value="{itn_title}" size="50" maxlength="750">

    {label:symptoms}
    {field:symptoms}

    {label:cause}
    {field:cause}

    {label:resolution}
    {field:resolution}

    <input class="button green" type="submit" name="submit" value="Submit">
{/exp:channel:form}

```

*** ADDED *** This is on IIS you mentioned htaccess, but with this site I have to use web.config. I have the following:

```
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="index.php" />
            </files>
        </defaultDocument>
        <rewrite>
            <rules>
                <rule name="index.php" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{R:1}" negate="true" pattern="^(pdfs|css|js|swf|skins|plugins|images|tools|themes|admin|index\.php)" />
                    </conditions>
                    <action type="Rewrite" url="/index.php/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

```
> 0 votes

---
Tags: ee2, pixelandtonic, wygwam, channel-form, saef
---


# Question
Title: Strict URLs / Removing one template group name
I would like to have 'strict URLs' enabled, but see I have to include the template group name in the URL for the pages to link correctly (else the 404 shows).

All groups are fine but one. I have a group called 'site' where all misc pages are listed.

Is there a way to have only this folder removed similarly to index.php with the htaccess?

Thanks

# Answer
> 3 votes
Depending on usage, you may want to just use the Pages Module, which lets you configure custom URLs and connect them to the template of your choice. I use this quite a lot in my setups.

# Answer
> 2 votes
You're not actually hiding index.php with .htaccess, you're adding it (hidden) to the URL a person accesses. So you're not going to be removing (hiding) the template group, you'll be adding it the urls that require it. And that I think is the problem - knowing what URL's require the addition.

The only way I can think of is to hard code the template segments to identify when it should be added:

```
RewriteCond $1 ^(sitemap\.xml|sitemap_index\.xml|fb-page)$ [NC]
RewriteRule ^(.*)$ /index.php/site/$1 [L]

```

In the above example I have 3 templates in the 'site' group I want to be accessible directly:

* sitemap.xml
* sitemap\_index.xml
* fb-page

---
Tags: htaccess
---


# Question
Title: How do I add a new action in update method of my .upd module file?
I can't find any resources explaining how to use the update() method of a .upd file in module development. All the tutorials gloss over it saying things like;

> "we don't need this right now, so we just return TRUE"

I do need it - I'd like to add another action into the database without having to reinstall my module, can anybody point me in the right direction please?

# Answer
> 3 votes
@naboovallay said it all really, but seeing as I had exactly the code you wanted already open, I figured I'd paste it...

```
function update($current = '') {
    if ($current == '' OR $current == $this->version)
        return FALSE;

    if (preg_replace("/[^0-9\.]/", '', $current) < '1.1.0') {
        //###   Create ACTion IDs for the relevant functions   ###
        $formActions = array(
            "google_feed"
        );
        foreach ($formActions as $method) {
            $data = array(
                'class' => $this->class,
                'method' => $method
            );
            $this->EE->db->insert('actions', $data);
        }//###   End of foreach
    }

    return TRUE;
}//###   End of update function

```

Most add-on developers store the version details in a config file in root of the module, so that can be easily read in by the construct...

```
//###   PHP5 Constructor   ###
function __construct() {
    require PATH_THIRD.'seo/config.php';

    $this->EE =& get_instance();
    $this->version = $config['version'];

```

...hence the version number of the build we can compare to.

Config.php

```
<?php
$config = array(
    'name'              => "SEO",
    "class"             => "Seo",
    "version"           => "1.1.0",
    'nsm_addon_updater' => array('versions_xml' => 'http://peteralewis.com/releases/seo/feed')
    );

```

# Answer
> 2 votes
First you need to get the version of your add-on so know if you should run any update functions or not. Replace the "ENTER\_YOUR\_CURRENT\_VERSION\_HERE" with the current version of your add-on. You could do this like this:

```
public function update($current = '')
{
    // Is the current version (from database) lower then the version for your current add-on?
    if ($current < ENTER_YOUR_CURRENT_VERSION_HERE)
    {
        // Do something to update to version X.X.X
    return TRUE;
    }
}

```

Then you could just keep adding these IF-statements for all version updates. This approach is pretty basic, if you an add-on with multiple version and releases here and there you should make this functions a little better with loading new version updates from flat files or something better. Let's say a user wants to update 3 version in a row, then you want all the updates to run after each other. Then you need a better loop code to execute all updates.

Also when you are done you need the function to return TRUE.

# Answer
> 2 votes
There is a `version_compare` function that can help simplify version comparison conditionals. See this example in the documentation.

---
Tags: add-on-development
---


# Question
Title: Occurrences display in Solspace Calendar
I'm using the calendar:cal tag to display a list of upcoming events.

I'm having an issue where the first occurrence date displays as the next event date, rather than the next occurrence.

How can I code it so the event date is the next occurrence rather than the first event date?

```
{exp:calendar:cal date_range_start="today @ midnight" show_years="1" pad_short_weeks="n" event_limit="10" status="Open|Featured"}

    {if no_results}
        <p>There are no upcoming Events.</p>
    {/if}

    <div class="event">
        <div class="date">
            <span class="day">{event_first_date format="%j"}</span>
            <span class="month">{event_first_date format="%M"}</span>
        </div>
        <div class="summary">
            <h3><a href="{path="events/view/{categories}{category_url_title}{/categories}/{url_title}"}">{title}</a></h3>

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

```

# Answer
> 1 votes
You should be using {event\_**start**\_date} instead of {event\_**first**\_date}.

{event\_**first**\_date} will always be the date of the first occurrence of an event (i.e. the first date of your event), whereas {event\_**start**\_date}, when used in {exp:calendar:cal}, will be the start date of each occurrence.

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


# Question
Title: Removing <p> tag from weblog text input field
I have a field in my weblog where a price can be entered on my site which is run with EE 1.7.1. In the template, I have a javascript code that adds a comma and a dollar sign. The problem is that in the latest weblog entries, it is sending the entry field to the template wrapped in paragraph tags. The tags don't show up when I look at the weblog itself, but when I inspect where it should be on the page, the source code shows the tags.

I have tried adding script to remove the tags, but it seems like the html tag is crashing the code.

My code, both for removing the tags and for adding the comma and dollar sign is

```
    function checkP(p){
        if(p.substring(0,3) == "<p>")
            p = p.substring(3,s.length-4);
        return p;
    }

    function stripTags(p){
        var StrippedString = p.replace(/(<([^>]+)>)/ig,"");
        return StrippedString;
    }

    function addComma(amount){
        if(typeof amount == "string"){
            var a = checkP(amount);
        }else{
            var a = amount.toString();
        }

        if(a.length > 3){
            var x = a.substring(0,a.length-3);
            var y = a.substring(a.length-3, a.length);
            var b = x + "," + y;
            document.write(b);
        }else{
            document.write(a);
        }
    }

```

My code that is controlling the price is

```
    <div id="inv_price">
        {if cf_inv_msrp!=""}MSRP: <b>$<script>addComma(stripTags({cf_inv_msrp}));</script></b>
        {if:elseif cf_inv_price !="" AND cf_inv_price!="0"}Price: <b>$<script>addComma({cf_inv_price});</script></b>
        {if:else}<b>Call for Price</b>{/if}
    </div>

```

When I add an alert to addComma, it never gets called which leaves me to believe that the tags are messing up the script's call.

The code works for all of the other entries, and I've tried removing the price and added it again. For an example of what the script should output, you can look at this site.

# Answer
> 3 votes
Go to this field via Admin \> Channel Administration \> Channel Fields \> Group \> Field and switch the formatting back to XHTML confirm and then back again to none. When switching EE should show a checkbox before confirming asking if you want existing fields to be reformatted. Check this.

Alternatively keep as XHTML in EE and use a plugin to alter the rendered format in template. I created a plugin to do this on Devot-ee. http://devot-ee.com/add-ons/remove-html

---
Tags: custom-fields, ee1, javascript, tags
---


# Question
Title: Is there a way to display playa fields inside my matrix field?
I have searched high and low for answers to why my fields are not displaying properly or displaying data I need.

I am basically trying to get the url for the playa entry selected in the backend to the frontend with an anchor.

My template setup is this:

```
{exp:channel:entries channel="brands" dynamic="no" limit="100"}
                    <li class="brand five columns">
                        <a href="#">
                            {brand_image}
                            <img src="{url}" alt="{title}-image" />
                            {/brand_image}
                        </a>
                        <div class="band">{brand_logos}<img src="{url}" alt="{title}-logo" />{/brand_logos}</div>
            <div class="lookbooks">
<!-- start playa fields -->
                            <div class="columns two season">
                                    {lookbook_season} <!--this is the matrix field -->
                                    <a href="{link}" title="{season}">{season}</a>
                                    {/lookbook_season}
                            </div>
            <!-- end playa fields -->

                        <div class="columns two social">
                            <div class="columns eight">
                                <div class="s1" id="fbook"><a class="icon-facebook" href="{facebook_link}" title="facebook link"></a></div>
                                <div class="s1" id="twit"><a class="icon-twitter" href="{twitter_link}" title="twitter link"></a></div>
                                <div class="s1" id="insta"><a class="icon-instagram" href="{instagram_link}" title="instagram link"></a></div>
                            </div>
                        </div>
        </div>
{/exp:channel:entries}

```

This is the setup in the backend if you need to know it is in the attachment.

Has anyone ever had these problems before?

Thanks, Mark

# Answer
Try this for your matrix tag pair:

```
{lookbook_season var_prefix="mx"} <!--this is the matrix field -->
    <a href="{mx:link var_prefix='pl'}{pl:url_title}{/mx:link}" title="{mx:season}">{mx:season}</a>
{/lookbook_season}

```

To me it helps (and is sometimes required) to use var\_prefix parameter to make sure you're targeting the right variable. But in your case what you're wanting I think is the url\_title of the "link" playa field.
> 1 votes

---
Tags: ee2, matrix, playa, custom-fields
---


# Question
Title: How can I get my templates to work properly on my live site?
I have a serious problem with my site.

I have recently made some changes to a site and its templates.

I uploaded all the correct items to the server via Beanstalk and git with a push to the remote repo.

When I login I am perfectly fine going into the templates but when trying to view pages the correct templates are not rendering properly at all. When I go to the templates in the editor they are correct but they are not showing up on the frontend at all. It uses the wrong template which is not the correct one for the url.

Has anyone got any ideas at all as to why this may happen?

# Answer
Can you please clarify, is it that completely the wrong template is loaded or an out of date version of the template you have updated? Perhaps try synchronising the database and the files via Design \> Templates \> Synchronise Templates?
> 1 votes

---
Tags: ee2, templates, multi-site-manager, url
---


# Question
Title: What happens to channel entries / products when inventory reaches 0 in expresso store?
Curious what happens when inventory for a product reaches 0. Does the channel entry automatically change its status to 'closed' so it doesn't appear as an option? Does it stay visible but cannot be added to the cart? Is there some error messaging associated with it? Also, if it's possible to set it manually, is it a system-wide setting or per-product basis? Any guidance is much appreciated!

# Answer
The product will still show up in your templates, but the customer won’t be able to add them to their cart. The status will not change. As per the Product Tag docs you could do something like the following in your template…

```
{if total_stock} In Stock {if:else} Out of Stock {/if}

```
> 2 votes

---
Tags: expresso-store
---


title: Backup Pro(ish) and Cron Job

text:
# Question
Title: Backup Pro(ish) and Cron Job
I'm a newbie to Backup Pro / Backup Pro(ish), and also to Cron jobs, and was hoping someone could help as this is happening on every site I've tried to set up.

I have Backup Pro(ish) installed on a site now (I'm hosting with A Small Orange). If I go and click on the Backup Database tab, everything works great and a backup is created in the correct folder (above root). If I use the URL given to me under the "Cron Commands", it will create a backup. However, my Cron jobs are not creating backups. To create the Cron job, I went in and selected the frequency to create them, then pasted the full command (wget ?ACT=xx&type=db) into the command line.

It runs, as I get an email. Here is the message that I get (IP and correct URL are removed)

```
--2013-09-20 12:00:01--  <MYSITE>?ACT=xx Resolving <MYSITE>... xxx.xxx.xx.xxx Connecting to <MYSITE>|xxx.xxx.xx.xxx|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 0 [text/html]
Saving to: `index.html?ACT=xx.5'

     0K                                                        0.00 =0s

2013-09-20 12:00:02 (0.00 B/s) - `index.html?ACT=xx.5' saved [0/0]

```

Any other suggestions on what to look at?

Thanks in advance!

# Answer
OK, sorry for the delay in getting back to this, but I wanted to be sure things were working - and they are. In talking with the host, and running several tests, they had me switch from wget to curl, and I am now getting regular backups. Thanks to all for their responses and suggestions - and thank you, Eric, for a wonderful add-on!
> 1 votes

# Answer
I'm the developer behind Backup Pro(ish) so I may be able to help here.

First, the email you're receiving is from your systems Cron mechanism and not Backup Pro(ish). I can tell that just from the content of the email (BPs email is completely different). Really, I have zero control over that email; you'll have to contact your host to modify the setup on that if you're unable.

Now, when you run a `wget` command, which the basic Backup Pro(ish) Cron command uses, on some systems it'll save the output to the server unless instructed otherwise. One of the more irritating things about the `wget` program is that there's no standard installation or base configuration that's across all platforms. So, for example, on my systems, the command in Backup Pro(ish) doesn't save the output nor send an email. On yours, it does apparently. Your host should be able to help you with disabling `wget` file output when it runs.

Lastly, as to why it's not running, I'm just as confused as you are on that. But, with you confirming that pasting the Cron URL into your browser executes the backup successfully I'm confident the issue lies in your network.

One cause for this would be if your server doesn't know your site URL exists on the physical server then it doesn't know where to send the request. Weird, I know, but when you're setting up a server it's rarely a given that the server your site lives on knows it does outside of Apache (DNS would have to be configured on it). I've seen this many, many, many, many, many times in fact. A simple update to your server's host entry (as you would do in Windows or OSX) to tell your OS that your URL lives on itself should sort you out. Your host should be able to help there.
> 4 votes

# Answer
I haven't used this addon before but I see **index.html** in the email... shouldn't this be **index.php** to hit EE?
> 1 votes

---
Tags: cron, backup
---


# Question
Title: File fieldtype in Matrix error: "File cells don’t work within SafeCracker..."
In EE 2.7.0 I'm now getting "File cells don't work within SafeCracker. Use SafeCracker File instead" messages within Matrix cells that formerly used SafeCracker File as fieldtype and have now been changed to File. Same is happening with tests of new entries of File field type used in Matrix.

This is happening on the front end using Channel Form, and safecracker\_file module has been removed.

# Answer
this is a known bug and will be fixed in a release shortly.

This happened due to changes to Safecracker in EE 2.7 and the subsequent removal of Safecracker File.
> 1 votes

---
Tags: matrix, safecracker, safecracker-file, files, channel-form
---


title: mailing list auto approval subscription

text:
# Question
Title: mailing list auto approval subscription
Hello community and thanks you for reading this

I need for a client who run his website under expressionengine to modify the core to auto approve a user when he subscribe to the newsletter (mailing list plugin)

Basicly I want to keep the automatic email send by the system (i will modify the content and erase the link to confirm the subscription) and have a auto approve subscription. No need for the user to click to approve his subscription

Many thanks to someone who find the solution.

# Answer
It sounds like you're not going about this quite the right way. What I would suggest is that you remove the email confirmation step (set member accounts to register straight away). That way you don't need to worry about hacking EE internals to change the member registration process.

Next problem you want to solve is sending a "welcome" email. I would take a look at Postmaster to see whether that will meet your needs. But treat the "send welcome email on member signup" separately from whether or not member email addresses require confirmation.
> 1 votes

# Answer
Open system/expressionengine/modules/mailinglist/mod.mailinglist.php

then set

```
var $email_confirm = FALSE;

```
> 0 votes

---
Tags: list
---


# Question
Title: Freeform 4.1.2 EE 2.7 - forms not submitting
Freeform 4.1.2 EE 2.7 - I have my forms setup and when I submit the forms not submitting, not being redirected to the redirect template no notifications. Basically nothing is working. After I press submit it just redirects to the home page www.domain?ACT=70

```
{exp:freeform:form
    form_name="contact"
    return="Contact/thank_you"
form_id="1"
notify_admin="yes"
admin_notify="user@domain.com"
admin_notification_template="contact"
required="email"
require_captcha="yes"
}
    <dl>
    {freeform:all_form_fields}
        <dt><label>{freeform:field_label}</label></dt>
        <dd>{freeform:field_output}</dd>
    {/freeform:all_form_fields}
    </dl>
    {if freeform:captcha}
        <p>Please enter the word you see in the image below:</p>
        <p>{freeform:captcha}<br />
        <input type="text" name="captcha" style="width:140px;" /></p>
    {/if}
    <p>{freeform:submit}</p>
    {if freeform:no_results}
        <p>
            Specified form was not found. Please make sure you have
            specified the correct short name of the form in the
            <b>form_name</b> parameter.
        </p>
    {/if}
{/exp:freeform:form}

```

# Answer
> 3 votes
fond the issue, when using an index.html file as a site offline page causes the form to now work.

Removing the index.html and making the site live with the index.php file allowed the form to work

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


title: Developer notices, warnings, message

text:
# Question
Title: Developer notices, warnings, message
I constantly am getting the following messages in the developer logs:

```
Deprecated function decode_date() called in system/expressionengine/libraries/Functions.php(679) : eval()'d code on line 10. Deprecated since 2.6. Use Localize::format_date instead.

```

I tried Googling or search the forums/internets/stackexchange for answer on what exactly the message is trying to tell me, but I have no idea.

Site is running EE 2.6.1. Thanks for helping.

# Answer
> 3 votes
An add-on you are using is called a deprecated function - which means that the function still works, but it has been superseded by a different function, and EllisLab wants developers to start using the new one. (This can be a pain for devs, since most want to support older versions of EE as well, which won't have the new function, so compatibility workarounds are required.)

It's nothing to worry about - eventually the developer will update the code (presumably before the deprecated function is removed). You can safely ignore the message.

---
Tags: developer-log
---


title: Safecracker file path

text:
# Question
Title: Safecracker file path
I have a safecracker file displaying the URL twice:

```
 <a href="{contract}" target="_blank">View Contract</a>

```

It's displaying like so:

http://figdoylestown.com/figdoylestown.com/uploads/web-08.jpg

Any thoughts?

# Answer
I would recommend taking a look at your upload locations setup. It looks like something may be set incorrectly for the location's URL. (This could be setup through the CP or in your config.php)
> 1 votes

---
Tags: safecracker, safecracker-file
---


# Question
Title: File manager navigation/pagination doesn't work
I have a wierd problem with my 2.4.0 install. After I moved servers my file manager navigation/pagination (1,2,3) and the "thumbnail" option in the dropdown selection stopped working.

Clicking a navigation item just send the user to the site homepage. The URL it's trying to load is this (on hover): http://domain.com/system/C=content\_publish&M=filemanager\_actions&action=directory\_contents&tbl\_offset=15

I've tried re-uploing the entire /themes/ folder but that didn't do it. Everything else on the site is also working like it should.

I should also note that the file-uploading etc. within the window works - it's just the navigationi/pagination and "thumbnails" view that isn't.

Thanks

# Answer
> 1 votes
It looks like your Control Panel URL configuration may be incorrect in your config.php. You'll want to make sure the settings in the config match the URL you use to access the control panel, whether that's domain.com/system or domain.com/admin.php, etc.

---
Tags: file-manager
---


title: Mailing List Module not working

text:
# Question
Title: Mailing List Module not working
I'm using the following code in my template for a Mailing List form, but it doesn't seem to be working.

```
{exp:mailinglist:form
    list="default"
}
    <div class="form-group">
        <label for="email">Email address</label>
        <input type="text" class="form-control" id="email" placeholder="Enter email" name="email" value="{email}">
    </div>
    <input type="submit" name="submit" value="Submit" class="btn btn-primary">
{/exp:mailinglist:form}

```

The form seems to post though no email appears in my default mailing list. Any thoughts on what could be the issue? I'm on 2.7 and am using .htaccess to remove the index.php.

# Answer
It's a bug in ExpressionEngine 2.7. I've filed a bug report. Will be fixed in the next version.

There's some info on how to fix it on the ExpressionEngine bug tracker https://support.ellislab.com/bugs/detail/19733 and on the forum http://ellislab.com/forums/viewthread/237991/#1059052
> 2 votes

# Answer
Make sure you CAN send an email. Send a test email in the communicate window. Otherwise your code looks ok. communicate

Also, read this Emails sent via ExpressionEngine are never reaching their destination

Ok, can you receive the email from mailing list? I assume you are inputting a valid email. Docs say this

> The Mailing List is an opt in type, meaning that when someone adds their email address to the list, they are sent a confirmation email containing a link with an access code. Unless they click the link, their email address will not be added to the list. The opt-in link will expire in 48 hours. Conversely, when someone in your mailing list receives an email, there will be an “unsubscribe” link permitting them to remove themselves from the list\`.

Just tested your link. Yep, no email received. some one else having same issue

One last idea, the source shows action id 19.

```
<input type="hidden" name="ACT" value="19">

```

Make sure this action id is listed in db table exp\_actions.

Finally, and im guessing here, move this mailing list tag off the home screen to another template and retest. Forms submit to home screen. I wonder if this is causing an issue here?
> 1 votes

---
Tags: forms, 2.7.0, mailinglist, mailing
---


# Question
Title: Getting pagination to work w/ nested {exp:channel:entry} tags?
I'm working on a blog site that uses a base index file as a "driver", with embedded templates for all the important data. The embedded templates both have {exp:channel:entry} tags that display a certain # of blog entries. Each template is formatted differently per the certain # of blog entries being shown, as I wanted the last four entries to look different than the first four.

The issue I'm having with pagination is that in the index files {exp:channel:entry} tag, I've set the limit to 1, and now it's giving me 10 pages worth of results (which is the total # of entries I have), but what I really want is just normal pagination that shows eight entries per page, formatted as I normally do.

Here's the relevant code:

```
<? //Formats article page w/ embedded EE variables. ?>

{embed="home/header" page-title="Lean Articles"}
{embed="resources/subhead"}

<? //Container for multiple blog articles, 700px wide defined by Grid system. ?>

{embed="a_update/article-nav"}

{if segment_2 == "" || segment_2 == "category" || segment_2 == "P1"}

    <span class="rightcol-700">

<?//Embed main and side content for Homepage section of site.?>

{exp:channel:entries channel="aupdate" limit="1" paginate="bottom" orderby="desc" dynamic="off"}
    {embed="a_update/.hidden_main_content"}
    {embed="a_update/.hidden_side_content"}

       {paginate}
              <p id="pagination">Page {current_page} of {total_pages} pages {pagination_links}</p>
      {/paginate}

{/exp:channel:entries}

    </span>
</div>

```

# Answer
> 1 votes
It would be, but within those embeds are channel entry tags that have each display a limit of 4, with different styling, such as:

```
<div style="width:400px;float:left;padding-right: 30px; border-right:solid 1px #3e3e3e">
    {exp:channel:entries channel="aupdate" limit="4"}
                    <div style="font-size:14px;color:#2b637e;font-weight:bold;line-height:1.2em">
                        <a href="{site_url}/a_update/{url_title}" style="text-decoration: none;">{title}</a>
                    </div>
    <?//Article date token, taken from Date field in Article channel. ?>
                    <div style="font-size:11px;color:#959190;line-height:1.6em">
                        {entry_date format="%F %d, %Y"}
                    </div>
    <?//Article Banner Image.?>
                    <div>
                        {exp:ed_imageresizer image="{article_image}" maxWidth="200px" maxHeight="80px" class="banner_image"}{/exp:ed_imageresizer}
                    </div>

     <?//Article summary token, taken from Summary field in Article channel. ?>
                    <p>{article_summary}</p>
                    <div>
                        [ <a href="{site_url}/a_update/{url_title}">read more</a> ]
                    </div>
                    <br clear="all">
                    <hr>
    {/exp:channel:entries}
</div>

```

And the second embed:

```
{exp:channel:entries channel="aupdate" limit="4" offset="4"}

<div style="width:165px;float:left;padding-left:30px;">
        <div style="font-size:12px; color: black;font-weight: normal;">
            <p><a href="{site_url}/a_update/{url_title}">{title}</a></p>
        </div>
        <div style="font-size:11px;color:#959190;line-height:1.6em">
            {entry_date format="%F %d, %Y"}
        </div>
        <p>{article_promo}</p>
        <hr>
</div>

{/exp:channel:entries}

```

So if I set the limit to 8, what happens is that it returns all my results squared, effectively, displaying way too many results/duplicates on the screen.

# Answer
> 0 votes
Sounds like you just need to change `limit="1"` to `limit="8"` on your channel:entries tag unless I'm missing something.

---
Tags: templates, pagination
---


title: Channel Forms used for inline editing

text:
# Question
Title: Channel Forms used for inline editing
Has anyone had any luck with using EE 2.7.0 with the new Channel Forms to perform inline/on page editing for logged in users? I was attempting this using a similar approach to the ajax driven form entry sample from the docs here by opening the form in an embed template, but I am having a hard time sending the template field to the embed.

What is the best way of retrieving the field name and making it, say the ID of the element being edited? Would this need to be handled vie PHP in templates or can I extract that another way?

# Answer
> 4 votes
I ended up getting what I need using the jquery ajax form example shown in the docs here and using a jquery dialog box to open up an edit field if they were logged in and authorized. If all were met, an edit button shows and opens a dialog with this:

```
            //    EDIT MODAL
    $(".editPage > a").click(function(e){
        //  Prevent default click action on anchor
        e.preventDefault();

        //  Get link from html markup
        var editLink = $(this).attr('href');
        var title = $(this).attr('title');

        // Build div contents
        var modal = $('<style>button.ui-button.ui-widget.ui-state-default.ui-corner-all.ui-button-icon-only.ui-dialog-titlebar-close{margin: -10px 0 0 96%;}</style><div id="edit_modal"><iframe id="editFrame" width="800" height="800" src="'+editLink+'" frameborder="0" allowfullscreen></iframe></div>').appendTo('body');

        $("#edit_modal").dialog({
            buttons: {
                'Save': function(){
                    $("#editFrame").contents().find('form #submitMe').click();
                },
                'Cancel': function(){
                    $(this).dialog('close');
                }
            },
            title: title,
            modal: true,
            width: 'auto',
            minHeight: 800,
            resize: 'auto',
            autoResize: true,
            close: function(event, ui){
                location.reload(true);
            }
        });

        // Open the modal
        $("#edit_modal").dialog("open");
    });

```

Could probably be cleaner, but it works great.

---
Tags: ee2, templates, inline-editing, channel-form
---


# Question
Title: Using Next/Previous entry and looping back to the first entry
I have a JQuery slider that, for each slide, needs to show what slide is coming next. That is, at the bottom of each slide, it will say, Next: Lorem Ipsum Dolor--the headline of my next slide.

I'm thinking the best way to do this might be to make the slides channel entries, and use the Next Entry tag to pull the name of the next entry.

Only problem is, when I get to the last slide, the "Next" will be empty. Is there any way to link back to the first slide? Is there a conditional that tells EE, if there is no "next", then pull from the first slide?

Thanks

# Answer
It seems to me, you could achieve this with javascript more easily.

Basically, you would cycle through each slide and append the title of the next slide to it. If there is no next slide, take the title from the first slide.

Here's a really rough example: http://jsfiddle.net/alexroper/jLHwV/1/

If you want to do this programmatically with EE, it looks like the Advanced Prev Next Entry by Biber Ltd could work for you. There is an `{empty_next}` variable you could test with a conditional. But you're adding extra queries for each slide so you may run into performance issues as you add more slides.

Take a look at the documentation here: http://biberltd.com/en/documentation/software/advanced\_prev\_next\_entry

My guess is the EE plugin option would cost you more performance than the small amount of overhead you would add to browser rendering with the javascript option.
> 1 votes

---
Tags: next-prev
---


title: Wygwam field dissapearing

text:
# Question
Title: Wygwam field dissapearing
Planning to switch from editor to wygwam, and when activating for a field for trial I get a complete blank field. The editors input-window flashes for a second, but no buttons are visible during that sec. Then all goes blank.

I have re-installed wygwam according to the installation instructions at P&T, with manual upload and no "updater" involved. Same error regardless of Safari/Chrome/FFox

# Answer
> 3 votes
Everything was due to me having DevDemons Channel Images installed. Without their WW-plugin they seems to kill each other :/

Many Thanks Brad at P&T for sorting this out for me!

/patrick

# Answer
> 1 votes
Same issue here using MAMP Pro - It appears that skin.js is being called, but is missing from the themes dir

```
Uncaught SyntaxError: Unexpected token < /themes/third_party/wygwam/lib/ckeditor/skins/wygwam3/skin.js?t=C3HH5RL:1

```

As far as I can tell, this file is not present in the download. My guess is that this was not carried over from a previous version so if you're doing a fresh install this file will be missing.

However, if you've got a previous version, just copy the skin.js file over from

```
/themes/third_party/wygwam/lib/ckeditor/skins/wygwam2/skin.js

```

and you should be back in business - if you don't have a copy of V2, then you'll need to email support and notify them of this missing file.

# Answer
> 1 votes
I ran into this problem today, and I think I figured out that the issue was caused by my browser caching the ckeditor.js file. So if you point your browser to this file on your site:

```
/themes/third_party/wygwam/lib/ckeditor/ckeditor.js

```

and then do a force-refresh of that page (hold shift while clicking refresh), it will force your browser to get the new js file. Then try viewing your publish page and the WYGWAM field should show up fine. Hope that is helpful!

---
Tags: wygwam
---


# Question
Title: path constant works locally, doesn't on dev
Using Focus Lab Master Config, I've defined these constants for my dev environment:

```
define('ENV', 'dev');
define('ENV_FULL', 'Development');
define('ENV_DEBUG', TRUE);
define('ENV_BASE_PATH', '/home/public_html/dev/');
define('ENV_BASE_URL', 'mywebsite.com');

```

In config.master.php I have this line:

```
$env_config['tmpl_file_basepath']        = ENV_BASE_PATH . 'templates/';

```

Now when I check my Global Template Preferences in the CP, I get this:

> ENV\_BASE\_PATHtemplates/

As a test, when I put ENV, ENV\_FULL or ENV\_DEBUG in the $env\_config line in stead, it prints correctly. On my local install there's no issue at all. Did I miss another setting needed to make this work?

# Answer
Do you have the `ENV_BASE_PATH` constant defined for *each* environment? It sounds like you only set it up under one.

The goal of this file (`config.env.php`) is to set constants *per* environment so you would want it to look something like the following:

```
if ( ! defined('ENV'))
{
    switch ($_SERVER['HTTP_HOST']) {
        case 'domain.com' :
            define('ENV', 'prod');
            define('ENV_FULL', 'Production');
            define('ENV_DEBUG', FALSE);
            define('ENV_BASE_PATH', '/home/public_html/dev/');
            define('ENV_BASE_URL', 'mywebsite.com');
        break;

        case 'dev.domain.com' :
            define('ENV', 'dev');
            define('ENV_FULL', 'Development');
            define('ENV_DEBUG', TRUE);
            define('ENV_BASE_PATH', '/home/public_html/dev/');
            define('ENV_BASE_URL', 'mywebsite.com');
        break;

        default :
            define('ENV', 'local');
            define('ENV_FULL', 'Local');
            define('ENV_DEBUG', TRUE);
            define('ENV_BASE_PATH', '/home/public_html/dev/');
            define('ENV_BASE_URL', 'mywebsite.com');
        break;
    }
}

```

You would obviously want to change the paths per environment, but that's the gist.

**Question though:** Why are you setting constants here rather than just letting the auto-created paths in `config.master.php` do their thing? What's the goal at hand?
> 3 votes

---
Tags: focus-lab-master-config
---


# Question
Title: EE 2.7 to 2.7.1 Upgrade Problem - Undefined variable: template_group
I had this error in one page that I have after upgrade.

```
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: template_group
Filename: libraries/Template.php
Line Number: 1959

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: template
Filename: libraries/Template.php
Line Number: 1959

```

Anyone has an idea what the problem is here?

**An Observation that might be useful or not**

Looking at libraries/Template.php, it seems to me that there is a chance that `$template_group` and `$template` will not be set based on the scope and conditionals. Is this wrong?

# Answer
> 1 votes
Somehow I got duplicate template groups. I just deleted the duplicates and now it works.

**UPDATE**:

This issue has been accepted by EE as a bug.

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

---
Tags: upgrade, 2.7.0, 2.7.1
---


title: plugin value in a template conditional

text:
# Question
Title: plugin value in a template conditional
I've frequently done this with success:

```
{if '{exp:my_plugin:my_method}'}My method returned true{/if}

```

Or the opposite also works:

```
{if '{exp:my_plugin:my_method}' == '0'}My method returned false{/if}

```

However, doing this for methods **with dynamic parameters** that also return a string instead of a boolean seems to be impossible - eg (inside of a channel entries tag):

```
{if '{exp:my_plugin:my_method entry_id="{entry_id}"}' == 'blah'}My method returned the word blah{/if}

```

Interestingly, calling the plugin outside the conditional at least once in the same template makes the conditional work as expected:

```
test output: {exp:my_plugin:my_method entry_id="{entry_id}"}
{if '{exp:my_plugin:my_method entry_id="{entry_id}"}' == 'blah'}My method returned the word blah{/if}

```

... but this is obviously far too weird and fragile to be useful!

Wondering if I'm missing something obvious or making a mistake?

# Answer
Digital Surgeons appear to have made a plugin which works around this particular problem:

http://devot-ee.com/add-ons/ifify
> 1 votes

# Answer
Try by using parse="inward" parameter within the plugin tag like:

```
{if '{exp:my_plugin:my_method entry_id="{entry_id}" parse="inward"}' == 'blah'}My method returned the word blah{/if}

```
> 1 votes

---
Tags: conditionals, plugin
---


# Question
Title: Need to create a very simple grid/gallery/css "table" layout inside channel:entries... without plugins
Trying to make some quick fixes for a client, despite being more or less a total EE n00b (I typically do more home-rolled CMS stuff).

I'm trying to do a very simple grid layout, x rows by 3 columns, inside a channel entries block. This mostly works:

```
{exp:channel:entries [...]}
    <div style="{switch='float:left;|float:right;|overflow:auto;'} width:33%;">
        [...]
    </div>
{/exp:channel:entries}

```

except where count mod 3 is 2, in which case my last row of divs has one float left & the other float right, so a big ugly gap in the middle.

I understand I'd need a plugin to have the modulo operator that I would usually use to write logic a little smarter than this switch. I also understand there are some plugins designed to generate layouts like this for me. However, I'm in a situation where I have no choice but to work on a production site, and like I said, I'm an EE n00b, so I absolutely want to avoid plugins.

Anyone have a solution? Other than going all web 1.0 on it and using table cells instead of divs? :D

Thanks in advance.

# Answer
Not sure there is any logic in EE templates required at all. Simply set the container’s width, the inner element’s width to one third of that, and float them all left… no? In the below example, we end up with a final row of just two, both sitting pretty to the left.

```
<style>
    .cont {
        width: 600px
    }
    .cont div {
        width: 200px;
        float: left;
    }
</style>
<div class="cont">
    <div>One</div>
    <div>One</div>
    <div>One</div>
    <div>One</div>
    <div>One</div>
    <div>One</div>
    <div>One</div>
    <div>One</div>
    <div>One</div>
    <div>One</div>
    <div>One</div>
    <div>One</div>
    <div>One</div>
    <div>One</div>
</div>

```
> 2 votes

# Answer
I've answered a question like this before. Have a look at this question/answer and it should outline how you can approach it.
> 0 votes

---
Tags: conditionals
---


# Question
Title: Expression Engine PHP & Embed & entry_id_from
i have the following Line:

```
{exp:channel:entries channel="orders"  entry_id_from="{embed:LAST_ID}" sort="desc" dynamic="no"}

```

LAST\_ID file :

```
<?
include '!mysql.php';
$last_id = @mysql_result(mysql_query('SELECT comanda_id_end FROM output_comenzi ORDER BY id DESC'),0);
if(!$last_id) $last_id = 0;
echo $last_id;
?>

```

How can I make that the LAST\_ID file to get PARSED, take the value and insert it into entry\_id\_from

Please help :)

# Answer
Your embed syntax is incorrect. `{embed:LAST_ID}` assumes that the template you're running has been embedded from within another template, and that the parent template's embed code had a parameter named `LAST_ID`, which has now been passed tot he template you're in.

What I think you are wanting to do it use the value of an embedded template in your `channel:entries` tag, which you can't do, because embeds run at the very end of the template engine, after all module tags have been run.

But you don't need an embed here, just PHP enabled in your template, set to "Input". Then, change your Channel Entries code to:

```
entry_id_from="<?php echo $last_id ; ?>"

```

Also, if the `output_comenzi` table is located in the same database as your EE tables, you can simplify your query using EE's database class.

```
$query = ee()->db->query('SELECT comanda_id_end FROM output_comenzi ORDER BY id DESC LIMIT 1');
$last_id = ($query->num_rows() == 1) ? $query->row('comanda_id_end') : 0;

```
> 1 votes

---
Tags: php, embeds, php-errors, template-scripting, querystring
---


title: Freeform Pro Custom CSV Export Order

text:
# Question
Title: Freeform Pro Custom CSV Export Order
Is there a way for me to export a custom column order when choosing CSV? I have one form with 27 fields of information that would be much easier to follow with a unique order. I would prefer to do the reorder on the export side for my clients needs. Solutions that use a Macro in Excel aren't ideal for this particular situation.

# Answer
> 3 votes
Yes - the fields will export in the order they appear in the admin. Click the "Edit Field Layout" button to control which fields are shown/hidden, and drag them into the order you want them to appear.

---
Tags: solspace-freeform
---


# Question
Title: More efficient way to check if Asset field is blank within Matrix
Need to display if a Asset field within a Matrix field has a file or not. While this works, the overhead is really high. Is there a way to write this with less overhead? Based on the EE template debug, here's the simplified snippet that causes the most lag:

```
{exp:channel:entries}
       {exp:playa:parents}
          {if '{matrixfield search:assetfield="not IS_EMPTY"}{row_id}{/matrixfield}'!=""}
             I'm not blank!
          {/if}
       {/exp:playa:parents}
{/exp:channel:entries}

```

Using the search+row\_id is most efficient way I've tested to write it, but it's still some 2k queries/8sec vs the 100/.xsec the site normally has. With the Asset in Matrix, in Playa, in Entries I would expect some additional processing time. Open to any ideas to try!

# Answer
I have the same problem - did you ever discover a good way to get around the n+1 problem?
> 1 votes

---
Tags: assets, matrix, playa
---


title: Alternate control panel URL

text:
# Question
Title: Alternate control panel URL
Client has asked (insisted) that the site and the control panel live on different URL or subdomain. I've googled about and had a look.. I can't find much info. Before I start hacking the core.. any ideas on the best way to approach this?

So I want www.mysite.com/admin.php to redirect to a 404 or some other error page.

# Answer
I think it's probably doable. It may be a process of elimination to work out all the kinks as you go, but no core hack should be needed.

I'd suggest you move the system directory out of the main site's document root first.

You can remove admin.php from the main site. And copy it over to the admin subdomain. And you can rename it whatever you like.

You'll need to adjust the $system\_path variable in the index.php of the main site and admin.php of the admin site to match the new system folder location.

From there, you'll need to make sure the themes directory is accessible to both document roots, through a symlink.

The upload locations will need to be set with the full URL and an absolute path, so both sites can access the files.
> 2 votes

---
Tags: control-panel, url, redirects, subdomain, site-preferences
---


# Question
Title: Change price with modifier, instead of + add to price
I have a gift card that I'm including in my store, and I would like to have the total price change with a modifier, instead of adding a dollar amount to a base price. Is this possible?

# Answer
> 2 votes
The easiest way to do this would be have a base price of $0 then enter the total amount for each modifier so the price is adjusted accordingly.

---
Tags: expresso-store
---


# Question
Title: Solspace Freeform {freeform:edit_data:status}
Freeform 4.1.2

I'm attempting to edit the {freeform:edit\_data:status} on the front-end of my site like so:

```
{exp:freeform:edit
entry_id="{segment_3}"
form_name="referral_application"
notify_on_edit="yes"
restrict_edit_to_author="no"
return="/referrals#myreferrals/status_changed_success"
}
 <select id="status" name="status">
   <option value="{freeform:edit_data:status}" selected>
    {freeform:edit_data:status}
</option>
<option value="open">Approved</option>
 <option value="closed">Declined</option>

 </select>
    <input type="submit" class="btn btn-default" value="submit">

 {/exp:freeform:edit}

```

I saw post on Solspace that said it was going to be fixed in version 4.0.6 : http://www.solspace.com/forums/viewthread/13266/#54728

Has anyone had any success with editing a status?

# Answer
To edit the status on the front end, allow\_status\_edit="yes" needs to be added to the exp:freeform:edit form.
> 1 votes

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


# Question
Title: Does EE not like includes, requires and classes?
So i wrote a few simple classes to handle login, password hashing and query handling. They've all been tested and work... HOWEVER!

I placed these classes inside a template, let's call it /classes

When i used php's include "" and require "" it caused server errors.

I then resorted to using EE syntax to embed the classes template

```
{embed="/path_to/classes"}

```

So that only worked half way. The code below will work fine in classes template alone, but NOT if classes is embedded and the code below is ran on the parent template.

```
 $createPassword = new protectPassword;
 $securePassword = $createPassword->makePassword($passwrd);

```

So i guess my questions are, am i doing something wrong in EE, or does EE just not like / allow such things?

Any help is much appreciated! Thanks!

# Answer
> 2 votes
I'm afraid you're approaching EE in the wrong way. it's not a good idea to mash-up EE, templates and PHP in the way you're describing.

embeds {embed="template\_group/template"} are for templates only - not including any file you want.

You mentioned EE1, you can download the docs from Ellis Labs website, or view online here: http://ee1docs.com/development/index.html. I'd highly recommend you read the developer documentation which goes into creating classes for plugins, modules and extensions. These can then be accessed via tags from the frontend instead of using PHP in the templates. Also look at other examples and learn from them - Devot-ee has lot's to choose from and you may find there's something that already does what you need (don't forget to filter by EE1).

Using CodeIgniter and ExpressionEngine code in the right will give you lot's of power to tap into their own classes and methods.

If you're starting out in EE or have inherited a site that uses EE1, I'd highly recommend upgrading and moving to EE2.

# Answer
> 1 votes
Putting anything beyond the simplest procedural PHP inside your templates is not a good idea, and will doubtless lead to headaches.

I strongly suggest you write an add-on to house your custom code.

---
Tags: ee1
---


# Question
Title: Formatting number from the hit counter (how to add comma)
I need to display the number of visitors to a website on the homepage, and I'm wondering if there is a way to add formmating to the number output by the {hits} variable. http://ellislab.com/expressionengine/user-guide/templates/hit\_counter.html

I've tried a few plugins, like "number-formatter" and even the "price-format" but I think the issue is that the {hits} won't parse from within some of these plugin tags.

Is there a better way to display (and format) the total number of visits to any one page on a site with EE?

THANKS!

Mike

# Answer
> 1 votes
This is probably due to parse order. {hits} isn't tag specific, so probably gets parsed later than the plugins you're using to format the value.

Try using track\_views="one" parameter on the channel:entries tag you use to build the homepage (assuming you have an entry associated with the homepage), that will give you the equivalent of {hits}. Then use {view\_count\_one} in the template, which should get parsed prior to the plugin that formats it: Number formatter, Number Format, etc.

---
Tags: number-format
---


title: Where to find 2.6.1

text:
# Question
Title: Where to find 2.6.1
I purchased plugin that requires EE. 2.6.x however I am not prepared to do the changes needed for Safecracker in 2.7.x to upgrade that far.

Where can I find a download for previous versions of Expression Engine - I am a paying customer and cannot find it anywhere on the Ellis labs site. I emailed support but cannot create a "ticket" unless i have a support license.

# Answer
Even if you had a support license, the response from Ellis Labs will be:

But there could be light at the end of the tunnel...

Kevin Cupp to the rescue!
> 3 votes

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


# Question
Title: How does Freebie ignore segment_1 and know what template to use?
I am wanting to use Freebie to ignore segment\_1.

I want to use a 'programs' template group but dont want programs in the url.

for example: NO - domain.com/programs/cycling YES - domain.com/cycling

If I place programs in the Freebie segments, how does it know when domain.com/cycling is used to use the programs template? Because at this time it shows the sites homepage.

I've read about htaccess and the way the index.php is removed, but still dont see how it ignores segment\_1 and knows what template to use.

Thanks

# Answer
I can think of two solutions here:

1) Use the pages module. Then you can assign arbitrary URLs to use a specific template.

2) If you use Switchee or Ifelse in your site's homepage template to determine what to do. Usually I place snippets inside of each condition within those add-ons, to minimize embeds. Since the conditionals parse before the contents, you don't have to worry about running lots of unnecessary code in the template.

The decision really depends on how dynamic you need that first URL segment to be.
> 0 votes

# Answer
What we've done before is to add a folder with the name of the segment you wish to ignore, and put a separate .htaccess & an index.php file.

It's a trick often used for multi-language sites, but also could work here.

I may be wrong, but I believe Freebie cannot ignore segment\_1 from what I recall.
> 0 votes

---
Tags: url, segments, freebie
---


# Question
Title: Order entries by value in Matrix field column
How would I go about setting the order of entries in a "products" channel based on the value in a price within a matrix field? So for each product, there is a matrix field with columns of regular price, sale price, sale start date, sale end date, color (an option that rarely affects price anyway). But regular price and ale price are pretty well always the same regardless of how many color options there are for the given product. What I'm looking to do is basically this:

```
{exp:channel:entries orderby="{matrix_field:reg_price}" sort="asc" dynamic="no"}

```

Any way to do something like this? Do I need to first perform a query to determine what the active price is for the items in order to sort them by this field?

# Answer
> 1 votes
You should be able to sort by the first column of the Matrix field without doing anything special. In your example, let’s assume that `regular_price` is the first column within `matrix_field`, the code would be…

```
{exp:channel:entries orderby="{matrix_field}" sort="asc" dynamic="no"}

```

To be honest, this solution is based on code I wrote two years ago, but it does work and is in production, but Matrix will have been updated. I recall I had to save the entries again to make this work. Try it, and let me know how you go.

---
Tags: matrix, conditionals, query
---


# Question
Title: DateTimeZone error when trying to set up Importer
Importer 2.2.2 seems to have installed correctly on EE 2.7, then receiving the below error when entering setup for the Module. Any thoughts on why the error is being thrown and how to fix it?

Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::\__construct(): Unknown or bad timezone ()' in D:\Inetpub\CBLink1\system\expressionengine\third\_party\importer\addon\_builder\addon\_builder.php:4097 Stack trace: #0 D:\Inetpub\CBLink1\system\expressionengine\third\_party\importer\addon\_builder\addon\_builder.php(4097): DateTimeZone-\>\__construct('') #1 D:\Inetpub\CBLink1\system\expressionengine\third\_party\importer\act.importer.php(65): Addon\_builder\_importer-\>timezone\_offset() #2 D:\Inetpub\CBLink1\system\expressionengine\third\_party\importer\addon\_builder\addon\_builder.php(702): Importer\_actions-\>\__construct() #3 D:\Inetpub\CBLink1\system\expressionengine\third\_party\importer\mcp.importer.php(139): Addon\_builder\_importer-\>actions() #4 D:\Inetpub\CBLink1\system\expressionengine\controllers\cp\addons\_modules.php(357): Importer\_mcp-\>index() #5 \[internal function\]: Addons\_modules-\>show\_module\_cp() #6 D:\Inetpub\CBLink1\system\codeigniter\system\core\CodeIgniter.php(319): call\_user\_func\_array(Array, Array) #7 in D:\Inetpub\CBLink1\system\expressionengine\third\_party\importer\addon\_builder\addon\_builder.php on line 4097

# Answer
> 1 votes
The latest version of Importer, as of this writing, is **2.2.3**. This version adds EE 2.7 compatibility. Please upgrade to this version and let us know if the issue persists.

---
Tags: solspace-importer
---


# Question
Title: Have forms been broken by new security issue?
I've just completed an upgrade from 2.5.3 to 2.7.0 (never want to do THAT again ;) ) and have run into an issue that seems to be coming from some changed security restrictions.

I have several simple pages that (in a nutshell)

* read the contents of a web page into a variable
* allow the selection (via radio button) of an e-mail address value for another variable
* mails the html content to the provided e-mail address

This has been done for the last year or so, no problems at all. Two lines of php have capture the content and another line sends the mail with the native mail() function. The page has used a form to post the html payload and email address selection back to itself (action="") and then based on the value of a couple hidden variable has either executed the mail() command or recycled the page with alternate html to be delivered as payload.

Since upgrading to 2.7 these form submission have stopped working, and I am confronted with that ugly grey box stating

**The following errors were encountered**

```
- The action you have requested is invalid.

```

Return to Previous Page

A "wonderful" generic message, which says absolutely nothing at all. (sigh)

I bit of time with google had me thinking this was being caused by a now mandatory CSRF token, but looking at my config I saw that CSRF protection was not even enabled.

I can't find a hint of anything in any log file anywhere, nor does anything appear on screen for a superuser. Also, the action does not complete, the mail is not sent.

I whittled one of the pages down to the following contents as a test:

```
<form action="" method="post">
   <input type="hidden" name="toAddy" value="test@example.com" />
   <input type="submit" name="submit" value="mail" />
</form>

```

And this also generated the error page.

Looking at a web console in FF, nothing is generated at all. I simply cannot find any specific error information anywhere which can lead me to a next step.

Has anybody seen this, or does anybody have an suggestions?

Any help is very much appreciated.

Andy

# Answer
It seems that for whatever reason my 2.5.3 was permitting these forms to function even though **"Process form data in Secure Mode?"** was set to YES. After the upgrade to 2.7 this restriction began to be enforced on my admin forms as well. The solution comes in two parts:

1. Add a hidden input field to carry the XID token
2. Find and use a suitable value to assign to XID. This turned out to be available through a global variable that had fallen out of the documentation, for whatever reason. The token is {XID\_HASH} and will deliver and valid XID at any time.

So, your hidden input field will look like this:

```
<input type="hidden" name="XID" value="{XID_HASH}" />

```

and when part of your hand-coded forms, will successfully pass through the Secure Mode restrictions.

**Here is some reading on the subject.**
> 14 votes

---
Tags: forms, ee2-upgrades, security
---


title: Custom asset metadata fields

text:
# Question
Title: Custom asset metadata fields
Is there anyway, or any plans to add the ability to create custom metadata fields for (Pixel & Tonic's) Assets?

I can't see any references on the docs, nor any content on the web directly relating to this.

Thanks

Dave

# Answer
you have to use the hook for that - here's a small extension that serves as a good example on how to achieve this - https://github.com/pixelandtonic/assets\_expiry\_date

In templates you can grab the data using the column name.
> 0 votes

---
Tags: assets, metadata
---


# Question
Title: How to pull channel entry data from Playa Links
So have you heard about the new Playa Links add-on? It's kind of great, showing you when entry A has selected entry X in its Playa field. But how do you pull the data from entry A into entry X? Is it the same way as pulling it from X to A?

Is this unclear?

# Answer
> 1 votes
Playa Links is just a convenience fieldtype for displaying relationships within the EE control panel entry screen.

To actually display your data in your templates, you have to use Playa's field tags or module tags.

---
Tags: channel-entries, add-on, playa
---


title: Custom Count Loop / Counter

text:
# Question
Title: Custom Count Loop / Counter
I'm trying to get a count inside a loop of a Matrix field. Normally I could just do:

```
{field}
  {row_count}
{/field}

```

And BAM, that would work perfectly. But not in this case. Because I need to do something like this:

```
{field}
  File 1: {image_field_1}
  Count: {row_count}
  {if image_field_2}
   File 2: {image_field_2}
   Count: ?!
  {/if}
  ------
{/field}

```

Which would output something like:

```
File 1: images/bobafett.jpg
Count: 1
------
File 1: images/lukeskywalker.jpg
Count: 2
------
File 1: images/jabba.jpg
Count: 3
------
File 1: images/darth.jpg
Count: 4
File 2: images/obiwan.jpg
Count: !?
------
File 1: images/r2d2.jpg
Count: 5
------

```

I've tried doing this with PHP:

```
<?php $count = 1; ?>

{field}
  File 1: {image_field_1}
  Count: <?php echo $count; $count++; ?>
  {if image_field_2}
   File 2: {image_field_2}
   Count: <?php echo $count; $count++; ?>
  {/if}
  ------
{/field}

```

But I think because of parse order, even entries that don't contain {image\_field\_2} render the PHP, so the count goes completely out of sync:

```
File 1: images/bobafett.jpg
Count: 1
------
File 1: images/lukeskywalker.jpg
Count: 3
------
File 1: images/jabba.jpg
Count: 5
------
File 1: images/darth.jpg
Count: 6
File 2: images/obiwan.jpg
Count: 7
------
File 1: images/r2d2.jpg
Count: 8
------

```

I've tried changing PHP to Output and Input and Output works best for me, because Input just parses '1' for the count every time. I think mainly down to parse order again.

I tried looking for a small plugin to do something like this for me, that would stop PHP being in the template AND would sort any parse order issues.

*help*

# Answer
Go with Matt's JS idea. It's easily done with jQuery:

Here's working code for you. You'll just need to adjust your selectors.
**http://jsfiddle.net/gxFdH/1/**
> 0 votes

# Answer
Jason, is JavaScript totally out of the picture for this?

Also, what's your PHP expertise like? I've solved similar issues in the past using a custom plugin and a static PHP variable. Basically, you can try setting the channel:entries field around the matrix to parse="inward", so it runs first, and have a plugin with a method that outputs and increments a static variable each time it's run. Parsing the outer loop first should help make sure your plugin only runs on actual output.

One tip is you'll want to add the "random" parameter (with no value) to your custom plugin tag, to make sure EE doesn't cache its output. Here's some pseudo-code around that:

```
public function current_count()
{
    static $count = 0;
    $count++;
    return $count;
}

```
> 1 votes

---
Tags: matrix, parse-order, loop, count
---


title: facebook connect button not showing

text:
# Question
Title: facebook connect button not showing
I'm using Solspace's Facebook Connect addon to add Facebook login to a site, but I can't work out why my Facebook connect button is not showing while using the following template code:

```
{exp:fbc:login permissions="email|publish_stream|read_stream"
    return_when_logged_in="site/home"
    return_when_logged_out="site/home"
    return_to_register="site/register"
    return_on_failure="site/fail"
}
{if fbc_logged_out == "y"}
    {fbc_login_button}
{/if}
{if fbc_logged_in == "y"}
    <a href="{path='logout'}" class="btnConnectSmall" >Your connected</a>
{/if}

```

Can anyone explain what I'm doing wrong?

# Answer
> 2 votes
Be sure to add '{exp:fbc:prepare\_page}' above the `<html>` tag of the page where you want the button to appear.

---
Tags: add-on, facebook, solspace-facebookconnect
---


# Question
Title: Solspace freeform Notifcation member_group setting
Using Freeform 4.1.2, Zoo Visitor 1.3.28

I'm sending notifications to the user who submits the form. The current\_user field here is capturing populated by zoo visitor ({screen\_name}). Works great. However, my notifications to the user are only going out to super admins (member\_group 1) if they submit the form.If a member from my Members group (member\_group 7) submits the form they are not notified. Am I missing a setting somewhere to allow this member group?

```
{exp:freeform:form
form_id="1"
inline_errors="yes"
required="name|email"
notify_user="yes"
return="referrals/success"
allow_status_edit="yes"
user_email_field="current_user"
}

<label>Broker: {embed="referrals/current_user"}</label>

<input type="hidden" value="{screen_name}" name="current_user" id="current_user" />

<input type="hidden" value="<?php echo $broker_name; ?>" name="broker_name" id="broker_name" />

```

....

Any thoughts?

# Answer
> 1 votes
You have

```
notify_user="yes"
user_email_field="current_user"

```

...which is good, but your "current\_user" hidden field is holding a `{screen_name}` as its value. Shouldn't that be an email address? Eg.

```
<input type="hidden" value="{email}" name="current_user" id="current_user" />

```

# Answer
> 0 votes
You may need to add the `user_notification_template="confirmation_email"` parameter to your form tag in order for the user notifications to be sent.

---
Tags: solspace-freeform, solspace, zoo-visitor
---


# Question
Title: Multisite Manager. Adding a second site question
Just a quick question really to anyone who has added a second or third site with EE and MSM. When integrating the second site is there a way round of allowing the client to carry on updating the first site.

Or is it a case of what we are doing now and stopping the client from updating until the integration of second site has been completed?

Any views would be greatly appreciated.

Dave

# Answer
> 1 votes
Assuming the client isn't in the Super Admins member group, you could remove control panel access from the member groups in which the client account(s) reside.

See the Member Groups documentation for the various permission settings you can assign or take away from groups.

# Answer
> 0 votes
An alternative to Jeremy's answer is to change the password(s) for the control panel login(s) the client uses. If they can't login, they can't change anything.

---
Tags: ee2, multi-site-manager
---


# Question
Title: How do I choose a different design template?
This might be really basic, but using a standard Expression Engine install, how do I choose a different design template for a specific channel? I'm not using Structure or anything like that.

I basically have two design templates, one for the front page, and one for articles. I'm displaying a portion of the content of each article on the front page. But want to link to the article itself from the front page. Then I want it to open that article using the other design template. Weirdly enough, I can't find any documentation on that.

# Answer
The basics are that a template is based on the URL, so say you have your default template group as "site", "site/index" will be your homepage - so your initial design can go in there. So that you can share elements (header, footer, etc), you might be using embeds to other templates.

But if you create other templates they will then be accessible on URL, so creating another template in the "site" group called "about" can contain completely different design template and be accessible via /about.

This may also mean using different template groups, for example creating a "blog" template group, would mean the URL /blog would go to the "index" of that template group.

Alternatively, you can route it through the "index" template...

```
{embed="includes/head"}
{embed="includes/header"}
{if "{segment_1}" == ""}
    {!-- HOMEPAGE --}
    {embed="content/homepage"}
{if:else}
    {embed="content/content-page"}
{/if}
{embed="includes/footer"}

```

The above will share the same header and footer templates, but allow complete freedom in different content templates. 2 new template groups are utilised in the above (includes and content).

You could approach it using

```
{exp:channel:entries channel="homepage"...}
    HOMEPAGE CONTENT
{/exp:channel:entries}

{exp:channel:entries channel="content"...}
    CONTENT CONTENT
{/exp:channel:entries}

```

But the overhead would be much greater and not recommended. In the same way that...

site/index template

```
{exp:channel:entries}
    {embed="content/{channel_short_name}"}
{/exp:channel:entries}

```

Will embed different templates based on your channel name (other templates would be in the "content" template group and named to match the channel short name). But again, will have the minor overhead of the initial channel:entries just to determine the channel - better to use segment conditionals.

There are many ways to approach EE, some right, some wrong, some clean, some messy, but ultimately it's what you prefer and what works for what you're trying to achieve.

To name but a few places to start...
> 3 votes

# Answer
Working with a (father) template acting as a router/controller for embedded (children) templates as suggested by Peter Lewis is a perfectly fine approach in some cases. A classical use case would be to have the same template used for lists and detail views.

However, in that case, have a look at switchee and ifelse by Mark Croxton. These will allow you to work with complex conditional logic without having EE parse each and every chunk of code or embed inside those conditionals. Big performance gain.

If you want to aim even higher, you could also look at Stash and the template partial approach. The learning curve is a lot steeper but the benefits can be huge. Here is a good article by Trevor Davis over at Viget.
> 1 votes

# Answer
You may want to look at the Pages module that ships with EE. It will let you define custom URLs and also select which template to use for specific entries.

It does, however, break out of the standard EE URL structure which is important to understand if you're building with EE.
> 0 votes

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


title: Specify redirect after password reset

text:
# Question
Title: Specify redirect after password reset
Is there any way to specify which template to redirect to after a user resets their password?

Currently, it takes them back to my reset password form, which is odd.

# Answer
> 1 votes
Use the parameter "return" such as return="page/entry\_id". Or get the MO'Variables Add-on and use return="{last\_page\_visited}".

---
Tags: redirects, solspace-user, password
---


title: PHP Error - date_default_timezone_get()

text:
# Question
Title: PHP Error - date_default_timezone_get()
Moved an EE site (v. 2.6.1) from local to development server. On the development server, I'm getting the following:

```
A PHP Error was encountered

Severity: Warning

Message: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Denver' for 'MST/-7.0/no DST' instead

Filename: libraries/Core.php

Line Number: 295

```

The site still loads, and I can access the CP, but this obviously is an issue. I host other EE sites on this dedicated server and they don't have the issue.

I am using master config and have played around with a few settings there from Google research, but nothing has helped.

The host has kind of left it to me, but I'm at a loss. Any suggestions on where to start?

Thanks in advance!

# Answer
> 2 votes
As the error says, PHP requires you to set a default timezone. This is actually quite a common error message when setting up a new server (or local development environment) with PHP.

You need to find your php.ini file on the server (ask your host where it is, or ask them to edit it for you). Find this part:

```
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =

```

It doesn't really matter what you set the timezone here to, since EE and most PHP scripts will override it anyway. You can set it to any of these supported timezones. If you're unsure, just uncomment the line (remove the leading `;`), and change it to read:

```
date.timezone = UTC

```

---
Tags: date, php-errors, timezone, get, default
---


title: Unique parent entries

text:
# Question
Title: Unique parent entries
I'm making lookbooks:
Each look has (parent) contains one or more items (children). Each item has a brand.
E.g. Picture 1 where a girls wears pants of Brand A, t-shirt of Brand B and a jacket of Brand A.
In my overview of Brand A, i want to show all pictures where the girls wears Brand A once. With this code Picture 1 appears 2x in the overview. How can I get this picture only show up once?
I must be looking at code for too long. I'm sure there's a simple solution to this. Thank you for your help.

```
{exp:channel:entries channel="items" search:item_brand="{last_segment}" dynamic="no"}
    {exp:playa:parents channel="looks" require_entry="yes"}
                    <img src="{look_image}" alt="{title}">
    {/exp:playa:parents}
{/exp:channel:entries}

```

# Answer
> 0 votes
I would use Stash for this, and split your data fetching from your markup assembly. Specifically, the `get_list` tag has a `unique="yes"` parameter that would allow you to only output each 'look' once:

```
{exp:stash:set_list name="looks" parse_tags="yes"}
  {exp:channel:entries channel="items" search:item_brand="{last_segment}" dynamic="no"}
    {exp:playa:parents channel="looks" require_entry="yes"}
       {stash:the-title}{title}{/stash:the-title}
       {stash:the-image}{look_image}{/stash:the-image}
    {/exp:playa:parents}
  {/exp:channel:entries}
{/exp:stash:set_list}

<ul>
   {exp:stash:get_list unique="yes" name="looks"}
      <li><img src="{the-image}" alt="{the-title}"></li>
   {/exp:stash:get_list}
</ul>

```

---
Tags: playa, relationships
---


# Question
Title: Can´t use different Wygwam 3.1.2-fields with Content Elements 1.5.5. because element_name is not working
This code is not working

```
{wygwam}
{if element_name=="Kasten"}
<div class="panel">{value}</div>
{if:else}
{value}
{/if}
{/wygwam}

```

When I use this code, all my wygwam fields will be shown, but not with the panel-formatting. Just as if the code would be

```
{wygwam}{value}{/wygwam}

```

Just loop through all wygwam fields and display them.

I have 2 wygwam fields. One is called "Fliesstext" and the other ist "Kasten". The "Kasten" (german for box) should get a grey background + a frame to look like a box.

Is this a Content Elements or a Wygwam issue?

# Answer
> 2 votes
Mailed KREA-Support, here´s the solution:

> {if "{element\_name}" == "Kasten"}

will do the trick.

---
Tags: wygwam, content-elements
---


# Question
Title: Upgrade method for fieldtypes (add-on development)
Has anyone written an upgrade for a fieldtype? I'm assuming so, but I've not actually ventured this direction, and there are zero docs in this arena.

Specifically in this case, upgrading a fieldtype with no settings to have per-field settings, which will update the fieldtype preferences in the DB etc etc.

Direction? Hacky style required?

# Answer
Well, it's something difficult for me to write everything here related to field type update :). let me try to give you some pointer.

While creating a field type, you were creating a $info array having "name" and "version". If you are going to update you field type, first step will be to higher the "version" value within the $info array.

Second thing: the field type file will have a function update like:

```
function update($from)
{
if($from < 2.0){
[process the stuffs which you need to update in the updated version of 2.0 in the case your previous version was less than 2.0]
}
}

```

Now it's depend on you, what you would like to update. If you would like to update the settings or field type display then you will need to modify the code within their function. In the update function you can re-structure database related stuffs.

I hope, my little pointer will help you.

Best Regards,
> 1 votes

# Answer
Although it isn't documented BKY is right, fieldtypes can have `update()` methods. Here's the relevant bit of code from addons\_fieldtypes.php:

```
// Update if version changed
$version = $installed[$ft]['version'];

if ($FT->info['version'] > $version && method_exists($FT, 'update') && $FT->update($version) !== FALSE)
{
    $this->db->update('fieldtypes', array('version' => $FT->info['version']), array('name' => $ft));
}

```

As with other `update()` methods you should return `TRUE` if the update was a success and `FALSE` if it's failed.

```
function update($from)
{
    if ($from == MY_ADDON_CURRENT_VERSION) return FALSE;

    if (version_compare($from, '1.1', '<'))
    {
        // Update Stuff
    }

    return TRUE;
}

```

I'd be happy to be proven wrong but don't think there are any helpers for retrieving/updating FT settings. You'd need to do all of the querying/serializing/base64 encoding\* yourself.

<sub>* Why, EllisLab, why?</sub>
> 1 votes

# Answer
Turns out the update method is available, BUT it's only triggered if you visit the global settings for the fieldtype.

Unfortunately, if you create a feildtype which doesn't have global settings, you're kinda boned and will have to find a workaround for querying/updating the installed version in the database and setting 'has\_global\_settings' to 'y' in exp\_fieldtypes.

Such a PITA.
> 1 votes

---
Tags: add-on-development
---


# Question
Title: Downgrade from Freeform Pro to Freeform - Error
Not needing all the features of Freeform Pro I attempted to downgrade to the regular version of Freeform 4.0.12. However, when I attempted to run the update script I get the following error:

> An Error Was Encountered Unable to load requested field type file: ft.freeform.php. Confirm the fieldtype file is located in the expressionengine/third\_party/ directory

What do I need to get rid of this error and get up and running on FF?

Thanks.

# Answer
I thought that you had solved the problem, but in reality I had to go into yet another table and remove all the Freeform Pro-specific fieldtypes. It is the exp\_freeform\_fieldtypes table.

Thanks.
> 0 votes

# Answer
You likely need to remove the entry for `freeform` from your `exp_fieldtypes` database table.
> 2 votes

---
Tags: solspace-freeform
---