# Question
Title: Problem with Matrix - case insensitivity on filenames
This is a follow on from How can I control the filenames of files uploaded via SAEF/Safecracker using Safecracker File in a Matrix? but is a different topic so I thought I should start a new question for future reference.

I have a Matrix field that contains a SafeCracker File field.

Images are uploaded to this field.

It appears that if I upload 2 images with filenames that are the same, but of different case, such as TEST.jpg and test.jpg then both images upload fine.

In the back end, on the entry form, the Matrix is displayed correctly with each image being shown.

However, when outputting the images on the front end the case of the file gets mixed up and I would see test.jpg output twice. The other file TEST.jpg is ignored.

Here is my test code. My Matrix field is called {photos} the Safecracker field within that is called {file}

```
{photos}
 <p>Row: {row_id}</p>
 <p>File: {file}</p>
{/photos}

```

Using the example files above I would *expect* to see.

```
Row: 1
File: /images/test.jpg
Row 2
File: /images/TEST.jpg

```

But in fact I see

```
Row: 1
File: /images/test.jpg
Row 2
File: /images/test.jpg

```

Since my server is case sensitive it is possible for both of these files to exist so it's causing a problem when the images are being output and the incorrect image is being shown in some cases.

Is anyone able to shed some light on this or try it out themselves to confirm the problem?

# Answer
> 1 votes
I ran into the same issue - after a bit of a hunt, I found where the file value was being pulled from - a database query in **system/expressionengine/models/file\_model.php**

That search wasn't case-sensitive, so I guess it was grabbing the first match it found.

My somewhat hacky solution was to change file\_model.php around line 334 and update the **get\_files\_by\_name** function to the following:

```
function get_files_by_name($file_name, $dir_id)
    {
        if (empty($file_name) OR empty($dir_id))
        {
            return FALSE;
        }
        //$this->db->save_queries = true;
        $dir_func = $this->_where_function($dir_id);
        $name_func = $this->_where_function($file_name);

        $this->db->$dir_func('upload_location_id', $dir_id);

        if (is_array($file_name))
        {
            $this->db->where_in('file_name', $file_name);
        }
        else{
            $this->db->where('file_name = "'.$file_name.'" COLLATE utf8_bin', NULL, FALSE);
        }

        $query = $this->db->get('files');
        return $query;

    }

```

I'm not sure if this adversely affects security or other file things, but so far seems to be doing the trick for me.

I posted a bug report here

# Answer
> 0 votes
Just wanted to update this question if anyone else experiences it. There's a solution posted in the Bug Tracker here: https://support.ellislab.com/bugs/detail/19512.

**EDIT: The following actually broke all my uploaded images on EE 2.5.2, so perhaps it works for 2.6.1, but NOT 2.5.2. Proceed with caution.**

But... if it's too much hassle to log in, here it is :-)

In system/expressionengine/models/file\_model.php, around line 345 change

```
->$name_func('file_name', $file_name)

```

to

```
->$name_func('file_name', $file_name.' COLLATE latin1_general_cs', TRUE)

```

Hope that helps someone out.

---
Tags: matrix, filename
---


# Question
Title: Are there hooks I can use to log file downloads
I'm working on a module to log some statistics on downloads from anywhere in the site. My module setup is fine, it installs and creates the necessary tables. Now I want to hook into the events, file downloads in particular and log this data to my new tables.

Are there any hooks exposed that I can use to see when this happens? It crossed my mind to try and intercept the event with javascript and log it asynchronously. But I am hoping there is a hook I can use instead. I haven't been able to find one though.

Any suggestions please?

# Answer
> 2 votes
No, there isn't any hook for it. You might see this question/answer Track logged-in user events which seems much similar to your need.

---
Tags: ee2, module, hook
---


# Question
Title: Can I natively define a default value for a custom field?
I have a channel for events, which includes the time, date and city that the event is in. In approximately 80% of cases, the event's city will be Sydney.

Is it possible for me to define Sydney as the default value so that it's pre-filled when a user creates a new entry? I'm sure there's a relatively easy way to do this using a fieldtype or extension, however I would prefer to have this functionality natively.

Also, I guess you could do this on templates, using code such as:

```
{exp:channel:entries channel="events" dynamic="no"}
  {if city}
    {city}
  {if:else}
    Sydney
  {/if}
{/exp:channel:entries}

```

but then I would have to remember to do this for every template that it occurs on, which is not ideal.

Cheers, for any help

# Answer
Not natively but you could throw a little JS into the field instructions as per this question.

```
<script>
  $(function(){
    if (document.location.href.indexOf("entry_id") == -1) { // if it's a new entry
      var field = $("#field_id_15");
      if (field.val() == "") { field.val("Sydney"); }
    }
  });
</script>

```

Obviously just replace that with the appropriate ID of your field.
> 3 votes

# Answer
What kind of fieldtype are using for cities? If it is a select fieldtype, you just need to put Sydney at the top of all options.
> 1 votes

# Answer
If the fieldtype for city is simply a text field, one option would be to split it in two and use the awesome entry type add-on to hide a custom field for an "other" city assignment. So in the entry type field, you would have two values - "Sydney" and "Other". When Other is selected, a new text field would appear that would accept the other city value as a text field. Or at least that's how you CAN set it up. Then you would have a conditional very similar to what you're looking for. Something like:

```
{exp:channel:entries channel="events" dynamic="no"}
  {if city == "Other"}
    {other_city}
  {if:else}
    {city}
  {/if}
{/exp:channel:entries}

```

Wherein the default value of {city} would be "Sydney", and {other\_city} would come into play only if the value of {city} was selected to be "Other". The entry type field can be radio button or dropdown list - and so dropdown list, with Sydney as the first option, would be a simple way to achieve what you're looking to do - and have it be quite user friendly to the site admins.

Hope that helps.
> 0 votes

---
Tags: ee2, custom-fields
---


title: exp:playa:parents not returning parents

text:
# Question
Title: exp:playa:parents not returning parents
I have two channels:

* locations
* meetup

"meetup" has a playa field called {chapter\_affiliation}

I have one entry in "meetup" with the playa field selecting one location.

I'm using EE 2.7.0 and Playa 4.4.5 (fresh install of Playa).

The following templates are copy pasted from the real templates.

My template for "meetup" properly shows the affiliated chapter using this code:

```
{exp:channel:entries channel='meetup'}
    {exp:playa:children field="chapter_affiliation"}
    <div><a href="/locations/{url_title}">Affiliated Chapter {title}</a></div>
    {/exp:playa:children}
{/exp:channel:entries}

```

My template for "locations" will not show the parent "meetup" and I've been staring at it for so long, I can't see why not. The following template will list all the locations, but nothing lists underneath any location, despite the above template properly showing the affiliation.

```
{exp:channel:entries channel="locations"}
    <h3>As Seen in {title}</h3>
    <ul>
    {exp:playa:parents channel="meetup"}
        <li><a href="{path={channel_short_name}/{url_title}}">{title}</a></li>
    {/exp:playa:parents}
    </ul>
{/exp:channel:entries}

```

My question is: What have I done wrong and how can I fix it.

# Answer
> 0 votes
Does your Meetup entry have an 'open' Status? An Entry Date in the past? No expiration date, or one set in the future? By default Playa will only show entries that meet those criteria, and if you want anything different you will need to specify the `status=`, `show_future_entries=`, and `show_expired=` params, just like with {exp:channel:entries}.

---
Tags: playa
---


# Question
Title: Using Channel Field to populate an individual page
Less of a question or more of an opportunity to see what other EE devs think.

The site I'm working on has a list of different City Markets and each Market has the same core pages like Directions & Parking, Admission & Policies, and Seating Policy.

Currently we're using Structure to create each one of the core pages under the specific City Market. As we continue to expand though I think it's going to be a bit unwieldy to have all these pages on the backend especially when there's an edit that needs to happen across all the City Markets.

My thought is that I create a Channel Field for each core page in the City Market Channel Entry. So Directions & Parking would be a field, Admissions & Policies would be a field, etc. Then I would use URL segment variables to designate which City Market Channel and which Channel Field to pull from to populate a core page in a City Market. So /austin/admissions would pull from the Admissions & Policies Channel Field in the Austin entry for City Markets.

Does that make sense and if it does what do you think about the solution?

# Answer
Yes, I've used this approach myself a number of times and it works well (though I've not used it with Structure, i would think the approach would still work), particularly if you are able to wrap the conditional with Croxton's switchee add-on to early parse the matching segments. So you'd have something like this:

```
{exp:channel:entries channel="markets" url_title="{segment_2}" disable="whatever|you|do|not|need" limit="1"}
    {exp:switchee parse="inward" variable="{segment_3}"}
        {case value="admissions"}
           {my_admissions_custom_field_or_more_than_one_if_needed}
        {/case}
        {case value="parking"}
           {my_parking_custom_field_or_more_than_one_if_needed}
        {/case}
        {case value="seating"}
           {my_seating_custom_field_or_more_than_one_if_needed}
        {/case}
        {case value="something_else"}
           {my_psomethingelse_custom_field_or_more_than_one_if_needed}
        {/case}
    {/exp:switchee}
{/exp:channel:entries}

```
> 1 votes

---
Tags: structure, content
---


title: low search by fields with relationship

text:
# Question
Title: low search by fields with relationship
I tried to use all possible way for search but it doesn't work.

So what I have:

Channel **countries**:

* field: country\_name (like UK, USA, Ireland, Russia and etc)

Channel **departments**:

* field: department\_title (like tech, commerce, finance)

Channels **careers**:

* field: title
* field: careers\_department\_title(relationship with channel **departments** by field department\_title)
* field: career\_role\_location(relationship with channel **countries** by field country\_name)

To display all from careers I do:

```
{exp:channel:entries channel="careers"}
  Job title - {title}
  Department title: {careers_department_title:department_title:}
  Role location: {career_role_location:country_name}
{/exp:channel:entries}

```

Now I need to do search by country or by departments.

```
{exp:low_search:filters query="USA"}
  {exp:channel:entries channel="careers" style="linear"}
   {career__country_name:country_name}
  {/exp:channel:entries}
{/exp:low_search:filters}

```

As result I have list of all countries, but I need only from specific country, in this example should be only USA, and no UK, Russia and other.

Can somebody advice how correctly to write this search by field which has relationship type?

My main goal to display dropdown menu and user can select search option: search by departments or by location.

Thanks in advance!

# Answer
Couple of things here. I don't think you need the Preparse option as Jeremy suggested, as you can filter by country/department ID, not by their actual names. Here's what to do:

### Results tag

Use something like this in your Results tag:

```
{exp:low_search:results channel="careers" query="{segment_3}"}
  code to display careers here
{/exp:low_search:results}

```

Make sure `{segment_3}` points to the **encoded query** in the URI. Something like `query="USA"` like you tried **will not work**.

### Create a search form

In that form, you can let the user choose a country or department. Something like this:

```
{exp:low_search:form result_page="search/results"}

  <select name="child:the_country_relationship_field">
    <option value="">Select country</option>
    {exp:channel:entries channel="countries" dynamic="no"}
      <option value="{entry_id}">{country_name}</option>
    {/exp:channel:entries}
  </select>

  <select name="child:the_department_relationship_field">
    <option value="">Select department</option>
    {exp:channel:entries channel="departments" dynamic="no"}
      <option value="{entry_id}">{department_name}</option>
    {/exp:channel:entries}
  </select>

  <button type="submit">Search!</button>

{/exp:low_search:form}

```

Make sure that you replace `the_country_relationship_field` and `the_department_relationship_field` with their corresponding relationship field names.

This combination should give you the filtered results.
> 3 votes

# Answer
The easiest method may be to use Solspace's free Preparse extension. It's a bit of a hidden gem. It essentially parses a template based on an entry id and stores it in a text field in the entry.

Low actually blogged about how to use Preparse with Low Search to make categories searchable. The same could be done for any fieldtype that doesn't use the standard `exp_channel_data` fields to store its data, such as a relationship or Playa field.
> 1 votes

---
Tags: search, relationships, low-search
---


# Question
Title: In matrix, set rows to correspond to values in a category
I'm thinking of using Matrix to get around EE's limitation in only having one image field for categories.

Is there a way to write a plugin that will automatically populate rows in matrix for each category?

Maybe the plugin could be executed after saving a category if there's a new value update a specific matrix field...

Hmm.

# Answer
There is a technique I have used in the past that uses channels as categories. Its pretty niffty as you can have any fields you like in the categories section.

• Create a channel called categories (Or whatever)

• Create a channel that you want to categorize (say, products)

• In the 'products' channel, add a Playa or native relationship FT to it that only looks at the 'categories' channel.

You can then use that relationship field display your entries for that cat. You can also create a better URL structure for SEO this way, and go to town on the categories fields.

It can be a bit of a pain getting your head around, but it is really powerful.

The whole native EE cats really need a good going over in my mind as they are quite limiting compared to teh rest of EE. I believe there are some new category hooks in 2.7, so fingers crossed a dev will take up the challenge.

As far as your question goes, I don't think there is anything available at the mo. I'll try and think of another way round, but the above is potentially a good way to go.

Hope it helps
> 1 votes

---
Tags: matrix
---


title: Building a sweepstake system

text:
# Question
Title: Building a sweepstake system
I am looking to build a sweepstake system that would send a unique code to the user every time they submit their email. What would be the best add ons to use to accomplish a system like this? Maybe safecracker could create entries and I could use the entry id & add another generic number to it creating the unique code eg: AUGCOMP23. Then maybe use Postmaster to send the unique code to them? Am I heading on the right track? How would I limit the amount of times they could enter?

# Answer
> 1 votes
What about the native mailing list? You can only subscribe once per list and each sweepstake would be separated, meaning the same email could enter different sweepstakes?

Are you looking at creating members for every email? Or is it a one off?

There are some plugins in Dev:otee that generate random strings that you could use if SafeCracker is the way forward.

Or you could use Profie:edit (or User etc) and create a Matrix field. When a member fills in the 'application' to sweepstake, a row is added to the Matrix which you can then use to check against to see if they have entered already.

The latter is probably the way I would go so you can view a member and see exactly what sweepstakes they have entered.

Sounds interesting. I looked in to something a little while ago. I'd advise you to checkout the law in your country regarding swepstakes. Depending on your idea, you don't want to get into trouble. In the UK a sweepstake MUST be free to enter. Or its classed as gambling I believe.

Good luck

---
Tags: safecracker, postmaster
---


# Question
Title: Why is the word "random" treated differently in the template parser?
We are experiencing some PHP errors due to a "too large" regular expression that is taking place during template parsing in Template.php. We noticed it was only occurring on templates that load an entry based on URL title and the URL title contains the word "random". The regular expression that is failing can be found in Template.php in the early 800 lines:

```
// Strip the "chunk" from the template, replacing it with a unique marker.
if (stristr($raw_tag, 'random'))
{
    $this->template = preg_replace("|".preg_quote($chunk)."|s", 'M'.$this->loop_count.$this->marker, $this->template, 1);
}
else
{
    $this->template = str_replace($chunk, 'M'.$this->loop_count.$this->marker, $this->template);
}

```

We're not sure how to go about fixing this issue.

# Answer
> 5 votes
From what I saw in a comment from Mark Croxton here: http://devot-ee.com/add-ons/support/stash/viewthread/8717

EE tries to cache tags that are used multiple times within the same template. To get around this, there's a "random" keyword that EE looks for that will cause it to use a separate marker for this tag (causing the tag to parse twice)

The problem is that it does a stristr for 'random', so if any of your parameters include the word random, or the tag itself does, it parses it an extra time.

It's possible to make a corehack by changing the line

```
if (stristr($raw_tag, 'random'))

```

to

```
if (stristr($raw_tag, ' random'))

```

It would be nice if there was a way to do this without a corehack, though?

---
Tags: templates, parsing, regular-expressions, random
---


title: ExpressionEngine 1.6.8 Admin login loop

text:
# Question
Title: ExpressionEngine 1.6.8 Admin login loop
I have uploaded a site into a sub folder onto my server and when I try to login into the admin area, it allows me to login, however when I go to click on any link, it redirects/loops me, logging me out and taking me back to the admin login page.

Site was working fine locally and the previous SQL which is live (redesigning the site) also allows me to login fine without this redirect problem.

Could it be anything to do with the fact it is in a folder on the server E.G.

httpdocs/new/...

I also thought it might be the .htaccess file throwing it off, maybe with the www. redirect and removing the index.php, but when the problem keeps arising with and without a .htaccess file.

Any ideas?

# Answer
If you have a second site on this hosting account, the cookies are probably getting in the way. Add this to your new site's config file and set the prefix to something unique:

$config\['cookie\_prefix'\] = "new";

**EDIT**
I just saw this was an EE1 site. Use this instead:

```
$conf['cookie_prefix'] = "new";

```
> 1 votes

# Answer
Check your config file to make sure all of your paths are linking to the sub-folder? Also, there could be a cookie path or name throwing it off?
> 0 votes

---
Tags: ee1, login, admin, loop
---


# Question
Title: How secure is EE? Will it pass penetration tests?
I'm looking into the possibility of using Expression Engine to build secure sites. How does the EE core hold up against penetration tests and vulnerability scans that check for things like cross site scripting and SQL injection?

Thanks, RS

# Answer
> 20 votes
We've had ExpressionEngine installs penetration tested in the past, most recently by the Security Operations team at one of the world's largest technology companies. The key takeaway was that the vast majority of issues were found in third-party add-ons. There were a few issues with ExpressionEngine itself; some of them were fixed in more recent versions of EE.

Many of the remaining EE issues and most of the add-on issues were only accessible via control panel URLs. In some cases, only to logged-in admins. I'm not sure if this is a vulnerability condition for you or if your architecture assumes that admins can be trusted and/or locks the control panel files down behind a firewall. In our case, we hardened the control panel folder in a few ways, including by requiring external OAuth authorization before a session is even started.

It's also worth noting that you're very likely to introduce SQLi and XSS vulnerabilities in your own code. Make sure you're fully testing all get/post params, escaping when displaying user-supplied data, etc.... I'm happy to elaborate if it's helpful!

---
Tags: security
---


# Question
Title: Postmaster add-on - Is it able to handle emailing file attachments?
Is the Postmaster add-on by Objective HTML able to send file attachments?

Basically I have a channel (Zoo Visitor member) which has a `SafeCracker File` field contained within it. All I want to do is to email the file to an Administrator when a channel entry is updated.

I couldn't find any mention of attachments in the documents for the add-on. Has anyone done this sort of thing before?

# Answer
Attachments are not currently supported simply because there hasn't really been much of a demand for them. But it has come up more recently. The attachments would work on a per-service basis, so the API needs modified to make that easier. I will put this on the radar for 1.4, which is bringing several additional changes to the API.
> 1 votes

---
Tags: postmaster, objective-html
---


# Question
Title: How can I get the id of a file that appears in a channel entry?
I have a channel called Knowledge Item, and one of its fields is a file. I want to embed the ID of the file in a hidden field in my template. I was doing this and thought it was working;

```
<input type="hidden" id="knowledge_item_entry_id" value="{entry_id}" />

```

until I realised that {entry\_id} refers to the entry id of the parent channel entry, not the file itself.

Is there a syntax to access properties like these from within a template please?

# Answer
You would just use the file field's tag pair and the file\_id varaiable like this:

```
{file_field_name}{file_id}{/file_field_name}

```
> 3 votes

---
Tags: ee2, templates, file-field
---


# Question
Title: Freeform / EE 2.7 : Reason: Secure Forms Timeout
I have a Freeform form running on a site. The form runs at sub.domain.com/folder/index.php and basically uploads a file and sends two emails.

Yesterday, all was working well while under EE 2.6.1. Today I updated EE to 2.7 and now anytime I submit the form I get this message :

> You are not authorized to perform this action - Reason: Secure Forms Timeout

The only thing that change is the EE upgrade. I'm using Freeform 4.0.12.

I did see this thread and double checked there was no redirect, but everything happens under the same folder on the same subdomain.

Thanks for any pointer you could provide.

# Answer
For now, Freeform is not compatible with EE2.7 - check the blogpost here http://www.solspace.com/blog/entry/compatibility\_with\_ee\_2.7.0/
> 3 votes

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


# Question
Title: How populate meta data with current entry's data
I would like to populate my meta tags, specifically Facebook Open Graph meta with the current entry's data. Most of it straight forward but am struggling with grabbing the image url.

The image field is a Simple S3 Uploader field

```
<head>
{exp:channel:entries dynamic="no" disable="categories|category_fields|member_data|pagination"}
<meta property="og:title" content="{title}">
<meta property="og:description" content="{intro}">
<meta property="og:type" content="article")
<meta property="og:url" content="{site_url}{if segment_1 != ''}/{segment_1}{/if}{if segment_2 != ''}/{segment_2}{/if}{if segment_3 != ''}/{segment_3}{/if}{if segment_4 != ''}/{segment_4}{/if}">
<meta property="og:image" content="**http://www.your-site.com/image.jpg"**>
<meta property="og:site_name" content="{site_name}">
<meta property="fb:admins" content="your-Facebook-page-user-ID">
{/exp:channel:entries}
</head>

```

# Answer
Since the Simple S3 Uploader is a normal fieldtype, you simply use the field name for the image field like:

```
<meta property="og:image" content="{custom_field_name}">

```

You can look at the documentation for additional tags that are available with the fieldtype.
> 2 votes

---
Tags: facebook
---


# Question
Title: How to process refund from control panel?
The exp:presso store website says that you can process refunds from the control panel, but there is no documentation on what the steps are to do this.

How do you process a refund from the control panel? We are using the Authorize.Net AIM payment plugin.

# Answer
Processing refunds from the CP is only supported on some gateways, and Authorize.Net AIM is not one of them unfortunately.

However, we will be adding this soon, so keep an eye out in the next version.
> 2 votes

# Answer
The ability to process refunds is based upon the gateway that you are using. Authorize.net AIM does not allow it however.

To process a refund you need to goto Store \> Orders \> Details for the order in question then you will see a button for refunds.
> 1 votes

---
Tags: expresso-store
---


# Question
Title: EE 2.70 + DevDemon Updater 3.2.6 not working for add-ons
I used DevDemon Updater to update an EE install from 2.5.2 to 2.7.0 -- worked great, as usual. But, now, Updater will not update any add-ons.

When trying to update any add-on, Updater looks like it's working correctly through each step--all the way to "Done." But it silently fails to make any changes to EE.

I don't see any PHP errors in the error log. I've checked the Updater settings, as well as the EE folders' file permissions. I can update add-ons manually (copying files) and also change things (content, settings) in EE via the control panel.

I've tried a variety of add-ons, including Assets2.1.4, Matrix2.5.6, Playa4.4.5, Wygwam3.1.2, low-reorder-v221, low-search-v231, snippet\_sync-135 and others. And, I can see that DevDemon is successfully unzipping these add-on files into a folder under system/expressionengine/cache/updater. The files, however, are never being copied into the proper third\_party folders.

Does anyone have this combo of EE 2.70 + DevDemon Updater 3.2.6 working properly? Are others seeing this issue?

# Answer
@ManuelPayano at DevDemon was able to replicate this, which were "addon install/update & XID issues" with between EE 2.70 and Updater 3.2.6.

DevDemon now has released Updater 3.2.7 with the fix, and it's again working great.
> 1 votes

---
Tags: ee2, devdemon, devdemon-updater
---


# Question
Title: XMLHttpRequest 200 OK but returning a Snippet instead of the appropriate XML
We've been having some trouble with getting XML from our server. It returns 200 STATUS OK but, like the title notes, it's not returning the XML that we pointed it to but instead is giving back a complete EE Snippet! It's really weird.

The XML is well-formed (validation passed with no errors) and the '`var url = "OUR URL"`' is well-formed (but can't share with you for obvious reasons).

Do you have any ideas as to why this would happen and what EE might be doing to make it happen?

---

EDIT 1: A quick note. When we add '`http://www.`' to the beginning of our domain it returns a `404 STATUS`. But when we remove it (leaving just our domain '`example.com`') it returns a `200 STATUS`. I'm not sure why this is.

Additionally, we are conforming to the Same Origin Policy (http://en.wikipedia.org/wiki/Same\_origin\_policy)

---

EDIT 2: The Snippet being returned contains the:

```
<!DOCTYPE html">
<html lang="en">
<head>
...
</head>
<body>

```

and we're calling the `XMLHttpRequest()` within the `<script>...</script>` within the body (contained in it's own template). Moving the `XMLHttpRequest()` into the `<head>` doesn't fix the issue.

---

EDIT 3: After changing the Template Manager -\> Edit Preferences -\> Type to Javascript it actually returns the Snippet as the web page (but only shows the markup). Vis., by doing this we're getting the same xhttp.responseText data. When we move the JS below into it's own template with the Preference Type to Javascript and {embed...} it we no longer get this problem but instead revert to the old one of getting a the Snippet instead of the XML.

---

Here's the Javascript:

```
<script type="text/javascript">
$(document).ready(function(){

});

function sendRequest() {

    var url = "OUR URL";
    var xhttp = new createXMLHTTPObject();

    if (!xhttp) alert("XMLHttpFactories Not Applied");

    xhttp.open("GET", url, false);
    xhttp.overrideMimeType('text/xml');

    xhttp.send();

    console.log(xhttp.responseText);

}

var XMLHttpFactories = [
    function () {return new XMLHttpRequest()},
    function () {return new ActiveXObject("Msxml2.XMLHTTP")},
    function () {return new ActiveXObject("Msxml3.XMLHTTP")},
    function () {return new ActiveXObject("Microsoft.XMLHTTP")}
];

function createXMLHTTPObject() {
    var xmlhttp = false;
    for (var i = 0; i < XMLHttpFactories.length; i++) {
        try {
            xmlhttp = XMLHttpFactories[i]();
        }
        catch (e) {
            continue;
        }
        break;
    }
    return xmlhttp;
}

sendRequest();

</script>

```

# Answer
Ok so this was ridiculous easy to fix.

What we did was move the XML from it's static file and inserted it into its own template within our active template group and it worked. So if you're having this problem just template the XML and go nuts.

All we had to change in our JS here was

```
var url = "OUR URL";

```

to

```
var url = "{path='<our template group>/<our XML template>}";

```
> 2 votes

---
Tags: ee2, javascript, xml, parsing
---


title: Transcribe translated URL segments

text:
# Question
Title: Transcribe translated URL segments
Anyone know if there is a way to get the default (original) template-group/template segments from a Transcribe translated URL?

**Example:** If the default language URL for a template-group is "example.com/en/news/" and the translated one for spanish is "examples/es/noticias/", is there some way of getting the original `{segment_2}` var ("news") if we are viewing the spanish version (where `{segment_2}` is "noticias")?

# Answer
> 2 votes
As long as the template translations are all in place in the module, the default behavior of the segment\_x variables should be to default back to their native ExpressionEngine template group / template names as defined in the template manager.

In the next version of Transcribe we're also introducing several additional early parse order variables such as {transcribe:segment\_1} which will be populated with the url segment shown in the browser.

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


# Question
Title: Automating migration from Matrix to Grid and Playa to Relationships?
I've just upgraded to EE 2.7.0 and I am thinking about migrating my use of Matrix to Grid and my use of Playa to Relationships. The main reason is that since I run more than one site off my EE install, using Grid and Relations would allow me to implement such fields on all sites, instead of just one since I only have a single license each for Matrix and Playa.

Moving manually would be a bit time consuming, especially when it comes to my Matrix implementation, so I am wondering if anyone has any suggestions for how to automate the process? I do own Solspace's Importer module, but I am not sure if it would be useable in this scenario.

# Answer
> 1 votes
In short: this is a doozy. Writing a routine to migrate a Playa field to a Relationship field wouldn't be too bad. But Matrix → Grid is another level - especially depending on what kind of columns you have in those Matrix fields (and if their fieldtypes are even Grid-compatible yet).

My guess would be that it's cheaper for you to license your additional sites at $118 a piece than spend many frustrating hours attempting to migrate your existing data. Or just use Grid and Relationship fields going forward and leave what's in-place as it is.

---
Tags: matrix, playa, relationships, grid
---


# Question
Title: Details on EE 2.7.0 Markdown Plugin and field format
Looking at the Changelogs for EE 2.7.0 I see there is now:

`Added Markdown plugin and field formatting option`

…but I don't see any details in the documentation. Is there any information available on the new plug-in and how it works?

# Answer
> 3 votes
From the plugin file in EE 2.7:

This plugin parses text using Markdown and Smartypants. To use this plugin wrap any text in this tag pair:

```
{exp:markdown}
Text to be **parsed**.
{/exp:markdown}

```

There are two parameters you can set:

* encode\_ee\_tags - ('yes'/'no') defaults to 'yes', when set to 'no' allows EE code to be rendered
* smartypants - ('yes'/'no') defaults to 'yes', when set to 'no' stops SmartyPants from running which leaves your quotes and hyphens alone

---

For basic syntax, EE is referring to http://daringfireball.net/projects/markdown/syntax

Also, PHP Markdown is being used, so anything you see here -- http://michelf.ca/projects/php-markdown/extra/ -- is available. Good for adding classes and ids, etc.

---
Tags: add-on, plugin, core, 2.7.0, markdown
---


title: Numeric Matching in channel entry query

text:
# Question
Title: Numeric Matching in channel entry query
I've got:

```
{exp:channel:entries channel="packages" dynamic="no" limit="1" sort="asc" orderby="package_order" search:package_order=">3"}

```

which should bring back a result but doesn't. The "package order" field is format "integer" but that should work shouldn't it?!

Am i missing something?

# Answer
Are you using version 2.7 of ExpressionEngine?

I've just looked at the docs for version 2.6 and there is no mention of being able to search numeric fields with `<` or `>`, so it looks like that may have been added to the latest version only.

If you take a look at the top righthand corner of the docs page on the EllisLab site, you can download older versions of the docs if you haven't yet upgraded.
> 2 votes

---
Tags: channel-entries
---


# Question
Title: How do I limit access to certain actions based on member role?
I only want a particular action to be available to certain user types. Is there a way to 'bake' this in when I register the action in my module install file, or do I need to check authorisation in the actual action method?

# Answer
> 2 votes
Actions (to clarify - entries in EE's `exp_actions` table) have no member group associations. If you want to allow only specific members or member groups to run an action, you will indeed need to write this logic inside your action method.

---
Tags: ee2, add-on-development
---


# Question
Title: Is there a helper function to generate a link to a member profile for a control panel view?
Does EE have any built in classes or helper functions to perform common tasks in module code?

In this instance, I want to generate an href to a member profile to use in a control panel view, from a member ID. I have looked in the expression engine core code and not found anything.

# Answer
> 2 votes
EE has many helper functions - see the Functions class documentation for example. Also, all CodeIgniter helpers and classes can be loaded and used.

If you take a look in the `models` directory, you'll find many helpful methods there as well.

Re: member profile - do you mean on the front-end, or in the control panel? (In either case, I believe the answer is "no" - just built it manually.)

---
Tags: ee2, control-panel, add-on-development
---


# Question
Title: Find channel entries with a field value greater or less than
I figured there'd be an easy way to pull entry values via a field. I'm building a site that has a basic search for a price (for property) and was hoping to do something like:

```
{exp:channel:entries channel="property" search="price < 200000"}
  <blah />
{exp:channel:entries}

```

However it seems I can only search for a value equal or not equal to a field value. Is that right or am I being particularly thick this weekend? I'm relatively new to EE, so apologies if it's a stupid question ...

Assuming I'm not being thick, are there any plug ins that would do that?

(Originally asked on StackOverflow; was suggested I asked here).

# Answer
> 3 votes
There is no `search=""` parameter in the channel:entries tag. There's only `search:custom_field=""` parameters, and those **won't** take less/greater than values (or in other words: ranges) in **EE 2.6.1 or lower**. They only accept (sub)string matching.

Add-ons that will give you support for filtering by range would be Solspace's Super Search or Low Search by yours truly.

# Answer
> 1 votes
The question wasn't about ranges exactly, the example was about a "less than a numeric value" query which according to the docs is possible? - http://ellislab.com/expressionengine/user-guide/modules/channel/channel\_entries.html#numeric-matching

# Answer
> 1 votes
Numeric Matching was added for the search:field\_name="" parameter as of EE2.7.0:

**From the Change Log:**

> Added \<, \>, \<=, and \>= numeric comparison operators to the Channel Entries search parameter.

**From the Docs:**

> If you have a field containing numeric data, you may use greater-than or less-than operators to search through them.
>
> search:numeric\_field="\<20"
> search:numeric\_field="\>20"
> search:numeric\_field="\<=20"
> search:numeric\_field="\>=20"

---
Tags: channel-entries, search
---


# Question
Title: Unformatted Textarea with Very Basic Text Styling
What's the best way to have an unformatted textarea field (meaning no `<p>` or `<br>` tags), but still allow the client to make text bold, italic, or add a link?

I often have to put content into a specific element (`<p class="summary">`, for example), so it can't be wrapped in its own `<p>` tags. And often for styling purposes the content can't have line breaks. But the content can still have bold or italic text or contain a link. Example:

> This is an example of some summary text. **Text can be bold**, or it can be *emphasized*, and it can even contain a link because these are all inline changes that don't affect layout.

Is there any client-friendly way (read: no html tags) to accomplish this?

# Answer
> 3 votes
Couple of suggestions:

* have you looked into using Textile or Markdown for your textarea?
* use a div.summary instead of a p
* CE String has methods to strip out tags from html, check `remove_tags` or `remove_tags_except` *(I use this a lot personally - lots of other useful methods too in this plugin)*
* Wygwam has a text-only mode that can be useful.

# Answer
> 1 votes
You could use the built-in **html formatting buttons** in EE, which can be enabled on a Textarea field. This would meet your requirement of no `br` or `p` tags without the need of a plugin to strip them out.

When the user clicks a formatting button the correct html is applied automatically, but it does leave the tags exposed (not a wysiwyg).

---
Tags: custom-fields, wysiwyg
---


# Question
Title: What's the best practice for rendering a high number of entries with exp:channel:entries?
I'm running into memory issues with a page that lists lots (hundreds, eventually 1000+) of little news items that consist of a title, date, and sometimes brief description. These are each channel entries, and I've taken the following steps to reduce memory usage and speed up page rendering:

* utilize the {exp:channel:entries} disable parameter (`disable="categories|category_fields|member_data|pagination"`)
* cache the entire page output with CE Cache (`{exp:ce_cache:it id="page" seconds="3600"}`)
* maintain a relatively high PHP memory limit (256MB)
* avoid rendering any more complex fields (Playa, Matrix, etc.), which are this case part of the entries but not used on the page

I also attempted to temporarily boost PHP's memory using `ini_set('memory_limit', '1024M')` before the exp:channel:entries call in the template, then `ini_set('memory_limit', '256M')` after, but this doesn't work. (Never tried this in a template, so I'm not surprised anyway.)

Are there any common practices or alternate approaches that would be appropriate here?

Or, is this just a nonsensical goal that's forcing a no-win outcome?

# Answer
> 2 votes
One thing worth looking at is how well the {exp:channel:entries} loop you describes performs in a template with nothing else--no embeds, plugins, etc., vs in the context of the actual page on your site. It's important to be sure that your general template / page architecture isn't putting too heavy a load on EE / your server.

In other words, in addition to what you've done above, the caching you do on other elements on the page, and across your whole site, may be very relevant. In general, I've found that caching more, and for longer times, across a whole site is a good way to leave space for queries / processes that need memory and processor time.

I've dealt with a bunch of EE memory limit issues over the years, and I rely heavily on CE Cache these days. Where possible, I especially like using the static cache in the mode where it totally bypasses EE. But, beyond caching, I've had to do some combination of the following:

* add more memory -- the obvious!!!
* use a CRON job to generate close-to-final-format results in the database, and pull those into the template using a simple {exp:query}
* ditch using EE channel or query tags, and do SQL queries directly from PHP (because, it's less overhead and you can really optimize your SQL)

# Answer
> 0 votes
Matt, a couple different approaches for you.

I assume this is a page hit frequently.

1) use pagination in your channel entries tag to reduce the number of results displayed

2) cache the page using template preferences

3) use stash to cache the channel entries fields you need. For example here is a rough framework for the approach - ( hint - you need to add some paramaters to these tags)

`{exp:stash:set_list [add params] save="yes" refresh="1440"}
{exp:channel:entries [add params] disable=[everthing except pagination]}
{stash:title}{title}{/stash:title}
{stash:date}{expiration_date}{/stash:date}
...And so on
{/exp:channel:entries}
{/exp:stash:set}`

Then later in the page use get\_list to display results in your markup.

4) Advanced: create your own plugin to return results, the use then stash to cache it. This approach worked us on one landing page because we needed to display up to 100 channel entries plus channel\_images for each ( extra queries) plus matrix (extra queries). Using the channel entries tag, the number of queries increased relative to the number of results. In the end 200+ queries and huge memory. Now, about 33 queries (doesnt increase relative to num of results), memory about 4mb and speed about 0.43 seconds.

Do you need pagination? If so, copy the query module, replace $sql with your own query and away you go.

5) use automatee to refresh your cache results

6) limit page to only one or two embeds

---
Tags: channel-entries, performance, memory
---


# Question
Title: How can I use returned values from plugin functions as parameters for other plugins? Example code and details provided
Below is all relevant code and the resulting output. **An explanation of my confusion follows.**

**Registration Script**

```
<?php
if(isset($_POST['username']))
{
    echo "1 - Start<br />";

    $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
    echo "2 - Username from POST - $username<br />";

    $password = $_POST['password'];
    echo "3 - Password from POST - $password<br />";

    $passhash = "{exp:encryption:create_hash password='" . $password . "'}"; //Contains echo 4
    echo "5 - Hashed Password Returned - $passhash<br />";

    $username2 = "{exp:encryption:print_username username='" . $username . "'}"; //Contains echo 6
    echo "7 - printed Username - $username2<br />";
?>
    {exp:database:add_user username="<?php echo $username2; ?>" passhash="<?php echo $passhash; ?>"} <!--Contains echo 8-->
<?php
}
?>

```

**Plugin: pi.encryption.php (excerpt)**

```
function Create_hash()
{
    $password = ee()->TMPL->fetch_param('password');

    //echo "Password to hash: $password<br />";
    // format: algorithm:iterations:salt:hash
    $salt = base64_encode(mcrypt_create_iv(PBKDF2_SALT_BYTE_SIZE, MCRYPT_DEV_URANDOM));
    $hashed = PBKDF2_HASH_ALGORITHM . ":" . PBKDF2_ITERATIONS . ":" .  $salt . ":" .
        base64_encode($this->Pbkdf2(
            PBKDF2_HASH_ALGORITHM,
            $password,
            $salt,
            PBKDF2_ITERATIONS,
            PBKDF2_HASH_BYTE_SIZE,
            true
        ));
    echo "4 - Hashed Password Method - $hashed<br />";
    return $hashed;
}

function Print_username()
{
    $username = ee()->TMPL->fetch_param('username');
    echo "6 - Pushing username through function - $username<br />";
    return $username;
}

```

**Plugin: pi.database.php (excerpt)**

```
function Add_user()
{
    $username = ee()->TMPL->fetch_param('username');
    $passhash = ee()->TMPL->fetch_param('passhash');

    echo "8<br />";
    echo "--->Username to database: $username<br />";
    echo "--->Passhash to database: $passhash<br />";

    $data = array(
        'User_ID'       =>null,
        'User_Name'     =>$username,
        'User_Passhash' =>$passhash.""
    );
    $query = ee()->db->insert('exp_user', $data);
}

```

**Printed output from running the registration script**

```
4 - Hashed Password Method - sha256:1000:axEzJMSQWDR/tyeeuWxDJC80YHJGlIm/:yk1KnSWyeXlwPb4vQThKAyXSF/yqwiID
6 - Pushing username through function - testUsername
8
--->Username to database: M10o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr
--->Passhash to database: M00o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr
1 - Start
2 - Username from POST - testUsername
3 - Password from POST - testPassword
5 - Hashed Password Returned - sha256:1000:axEzJMSQWDR/tyeeuWxDJC80YHJGlIm/:yk1KnSWyeXlwPb4vQThKAyXSF/yqwiID
7 - printed Username - testUsername

```

In my registration script which contains expression engine tags, I inserted some test prints to make it easier to follow the program execution.

**My code (if the world were perfect) retrieves a given username and password from POST. The password is encrypted with a plugin function. Then a second plugin function is used to add the username and the encrypted password to a database.**

The PHP parsing order is set to "Input", so the php is parsed before the EE tags. With this in mind, I am a bit confused why the PHP lines containing EE tags are all executed first as a group. Though that is confusing, that is not my main problem.

Look at output line #8. The $passhash sent to the Add\_user() method via the EE tags is not the value of $passhash that is generated and returned by the Create\_hash() method. Even though I explicitly send $passhash to the Add\_user() function, a completely different string is sent instead.

**$username, if passed directly to the Add\_user() method, acts as is intended and is properly added to the database.**

The problem I'm having with $passhash only happens when I'm using a result returned from a plugin function. I confirmed this by recreating the issue using $username. To see if the issue is consistent, I changed my code to pipe $username through the Print\_username(). It simply returns the string given, and is saved as $username2 in the registration script.

Demonstrated in the output line 8, $username2 is now having the same issue as $passhash.

**Now, my question:** How can I use returned values from plugin functions as parameters for other plugins without the latter receiving garbage?

# Answer
> 4 votes
What you're trying to accomplish would be better served using a module, instead of plugins in a template. With a module, you can create a true form action and use pure PHP, rather than fighting the template parser with the spaghetti you've got here.

There are good docs on building a module: http://ellislab.com/expressionengine/user-guide/development/modules.html http://ellislab.com/expressionengine/user-guide/development/module\_tutorial.html

In particular you want to create an action in your module-\>install function:

```
function install()
{
  $data = array(
    'module_name' => 'Module_name',
    'module_version' => $this->version,
    'has_cp_backend' => 'n',
    'has_publish_fields' => 'n',
  );

  ee()->db->insert('modules', $data);

  //here's where you create your action in the database
  //later on, you'll look up this action to POST to it
  $data = array(
    'class'     => 'Module_name',
    'method'    => 'register'
  );

  ee()->db->insert('actions', $data);
}

```

And then in your module you'd create a register method:

```
function register()
{
   //get the username & password from $_POST
   //hash the password
   //add the user to DB
   //redirect or print a message
}

```

You'll also need to create a form tag (you can call it whatever you want):

```
function form()
{
  $return_data = ee()->functions->form_declaration(array(
    'hidden_fields' => array(
      'ACT' => ee()->functions->fetch_action_id('Module_name', 'register'),
    ),
  ));

  $return_data .= ee()->TMPL->tagdata;

  $return_data .= '</form>';

  return $return_data;
}

```

Then you can print the form in a template on the front-end, and it will correctly POST to your form action:

```
{exp:module_name:form}
  <input name="username">
  <input type="password" name="password">
  <input type="submit" value="Submit">
{/exp:module_name:form}

```

---
Tags: plugin, parameters
---


# Question
Title: Setting up a blog-type CD page with links to detailed page
I'm new to EE, and I've been asked to update someone's site that has already been set up in EE - I'm floundering a bit here and don't know how to set up the page correctly (perhaps in over my head!). My terminology might not be up to snuff, so please bear with me. The code provided below was already in EE.

Goal: have a page (domain.com/store) that lists two types of CDs (artists own CDs, and OTHER CDs), where:

1. the CD cover for OTHER CDs and title are links to more detailed info (domain.com/store/CDname), and
2. full info is shown for OWN CDs (doesn't need to linked to its own page)

I can't, for the life of me, figure out what I need to do! Perhaps this is too much for just one answer, and perhaps I don't know enough to structure the question correctly...

The page template is:

```
{embed="inc/.head"}

{embed="inc/.nav"}

{embed="inc/.store"}

{embed="inc/.sidebar"}

{embed="inc/.footer"}

```

and the {embed="inc/.store"} is set up like this:

```
<div id="main"> <!-- #main, #wrap, and #content are closed in the .sidebar -->
    <div class="wrap">
        <div id="content">

    <div class="block">
        <h4 id="myrecordings">MY RECORDINGS</h4>
        <div class="block-content">
                <ul class="news" id="myCds"> <!-- FULL INFO FOR THESE -->

{exp:channel:entries channel="store" orderby="date" sort="asc" category="9"}
                        <li>
                            <div class="pic">
                                {if bc}<a href="{bc}" target="_blank">{if:elseif amazon}<a href="{amazon}" target="_blank">{/if}<img src="{cover}" alt="{title}" width="150" height="150" /></a>
                            </div>
                            <div class="details">
                                <h5><a href="{comment_url_title_auto_path}">{title}</a></h5>
                                <p style="font-weight:bold;">{subtitle}</p>
                                <p>{personnel}</p>
                                <p>{store_description}</p>
                                  <p style="font-size:18px;">{if bc}<a href="{bc}" target="_blank">Buy On Bandcamp</a> | {/if}{if amazon}<a href="{amazon}" target="_blank">Buy On Amazon</a> | {/if} {if itunes_link}<a href="{itunes_link}" target="_blank">Buy On iTunes</a>{/if}</p>
                                <p>{track_list}</p>
                            </div>
                        </li>
{/exp:channel:entries}
    </ul>
<div class="clear"></div>
                </div> <!-- /block-content -->
    </div> <!-- /block -->

<div class="block">
    <h4 id="other">OTHER RECORDINGS</h4>
        <div class="block-content">
            <ul class="news cdGrid"> <!-- PARTIAL INFO FOR THESE -->

{exp:channel:entries channel="store" orderby="date" sort="asc" category="14"}
            <li>
                    <div class="pic">
                        <a href="{comment_url_title_auto_path}"><img src="{cover}" alt="{title}" width="150" height="150" /></a>
                    </div>
                    <div class="details">
                        <h5>{title}</h5>
                            <p style="font-weight:bold;">{subtitle}</p>
                    {!-- <p>{personnel}</p>
                    <p>{store_description}</p>
                    <p style="font-size:18px;">{if bc}<a href="{bc}" target="_blank">Buy On Bandcamp</a> | {/if}{if amazon}<a href="{amazon}" target="_blank">Buy On Amazon</a>{/if}{if itunes_link} | <a href="{itunes_link}" target="_blank">Buy On iTunes</a>{/if}</p>
                    <p>{track_list}</p> --}
                    </div>
                </li>
{/exp:channel:entries}
                </ul>
                        <div class="clear"></div>
                    </div>
                </div>

```

# Answer
> 0 votes
For the /store/ page, continue as you are doing and have your two channel entry loops. The first loop currently hits category=9 for My Recordings. Continue this and output only the information you desire. Do the second loop on category=14 for Other Recordings and output only the information you desire.

Both of these areas would then link to individual item pages. You could have your template look to see if {segment\_3} exists. This would be the title\_url for each individual CD. If {segment\_3) exists, look at that specific item in a Channel Entry loop and depending on the category, output as appropriate.

Your URL structure could look like: \store\ - all items \store\cd\_name - output either as My Recording and show Other Recordings at bottom, or output as Other Recording and display as needed.

This can all be done in one template.

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


# Question
Title: Would like tips and advice on updating website URL and Server Path in EE1 to a subdomain
I'm doing a major re-desing of an old EE1 site and would like to stick a copy of the old site on the subdomain archives.mystie.com for future access. With EE2 there are wonderful addons like REElocate to make this process easier. I haven't found anything similar for EE1

I've updated my config and path fiels and I'm able to navigate the CP using the following URL structure

mysite.com/archives/systemfolder/index.php

I have a couple of questions.

## ONE

I can't seem to get it to work using the subdomain url archives.mysite.com/systemfolder/index.php

Not sure what could be preventing that, but if someone has some ideas I'd love to hear them.

## TWO

The paths to my file assets (images, css, js ect) are not updating. I must be missing some setting, but I just don't know what or where.

Due to limitations on newbies posting links I was not able to add the notes on what I've done so far inline. To read what steps I've taken go to http://webbdemo.com/files/moving-ee1-site-to-subdomain.txt

NOTE: Except for one, all "links" are config settings.

Thanks for any insights or solutions! Jules

# Answer
For your #1, can you browse static files (e.g., put a robots.txt in the root folder) at http://archives.mystie.com? Can you browse http://archives.mystie.com/robots.txt? Make sure that works, as a starting point.

From the point of view of EE, it doesn't really know that a subdomain is a subdomain--it's just a domain name / URL. So, in your config file, you should have things like this:

```
$conf['site_url'] = "http://archives.mysite.com/";
$conf['cp_url'] = "http://archives.mysite.com/systemfolder/";

```

And, for your paths, you'll want to use the full path (most likely), like:

```
$conf['system_folder'] = "/home/un/public_html/archives/systemfolder/";

```

For your #2, take a look in the control panel under: **CP Home › Admin › Weblog Administration › File Upload Preferences**

You'll need to update your file paths for each of your file upload destinations.

(Note that if you have hard coded full URLs to http://mysite.com/... in your content entries, those won't update.)

I think, if you tweak a few things, and double-check that you have the URLs and paths right, you should be good to go.
> 2 votes

---
Tags: ee1, migration, path
---


# Question
Title: Database connectivity error with EE on Network Solutions
I'm setting up a staging server on a Network Solutions site before preparing it to go live next week. I created a new subdomain pointing to /htdocs/staging/html so I can move system above root (plan to do the same to the live site; /htdocs/live/html). However I'm getting the infamous error message:

`An Error Was Encountered
Site Error: Unable to Load Site Preferences; No Preferences Found`

I've double checked the database settings and the tried using both the server alias and IP address. Username and passsword for MySQL have been checked and double checked. I'm sure someone has successfully hosted an EE site on Network Solutions and can hopefully give me an idea of what I might be doing wrong here.

# Answer
> 1 votes
Solution was to edit the correct file. I had my config file from the local dev site open instead of the staging site.

---
Tags: database, error
---


# Question
Title: Parse Error: syntax error.... eval()'d code
I'm pretty new to ExpressionEngine... I was asked to put pagination in for the following page, and I get the following error: Parse error: syntax error, unexpected T\_ENDIF in /mnt/stor12-wc2-dfw1/594049/www.somedomain.com/web/content/system/expressionengine/libraries/Functions.php(656) : eval()'d code on line 181

I don't know how to fix it, and it only appears when I put in the pagination code. Any ideas?

Thanks!

```
{if segment_2 == ""}
<div id="main">
        <div class="wrap">
            <div id="content">
                <div class="block">
                    <h4>NEWS</h4>
                        <div class="block-content">
                        <ul class="news">
                {exp:channel:entries channel="news" limit="6"  dynamic="off" orderby="date" sort="desc" paginate="bottom"}
                 {paginate}
                        <p id="pagination">Page {current_page} of {total_pages} pages {pagination_links}</p>
                    {/paginate}
                            <li>
                                <div class="pic">
                                    {if !slideshow}<a href="{url_title_path='news'}"><img src="{image}" alt="{title}" /></a>{/if}
                                </div>
                                <div class="details">
                                    <h5>{title}</h5>
                                    <p>{if "{content:has_excerpt}"}{content:excerpt}{if:else}{content}{/if}
                                    </p>
                                    {if video_embed != ""}{video_embed}{/if}
                                    {if slideshow}
                                    {slideshow limit="10"}<a href="{comment_url_title_auto_path}" style="float:left;">{exp:ce_img:pair src="{url}" max="100" crop="yes"}<img src="{made}" alt="{title}" />{/exp:ce_img:pair}</a>{/slideshow}
                               {/if}
                                    <a href="{comment_url_title_auto_path}" style="clear:all;">Read More...</a>
                                </div>
                            </li>
                {/exp:channel:entries}

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

                  {if:else}
                {exp:channel:entries channel="news" limit="1"  dynamic="off" orderby="date" url_title="{segment_2}"}
                <div id="main">
                            <div class="wrap">
                                <div id="content">
                                    {if slideshow}
                                    <h4 class="red">{title}</h4>
                                        <div class="block-content">
                                           {if "{content:has_excerpt}"}{content:extended}{if:else}{content}{/if}
                                                </div>
                                      <div class="coda-slider-wrapper">
                                            <div class="coda-slider preload" id="coda-slider-1">
                                                                            <div id="coda-nav-left-1" style="float:left;" class="top-arrow-nav"><a href="#" title="Previous">< Previous</a></div><div id="coda-nav-right-1" style="float:right;" class="top-arrow-nav"><a href="#" title="Next" >Next ></a></div>
                                                {slideshow var_prefix="slide"}
                                                <div class="panel" id="panel{count}">
                                                    <div class="panel-wrapper">
                                                        {if slide:caption}<p>{slide:caption}</p>{/if}<a class="xtrig" href="#{if slide:total_files == {count}}1{if:else}{exp:mx_calc expression="{count}+1"}{/if}" rel="coda-slider-1">{exp:ce_img:pair src="{slide:url}" width="715" height="536"}<img src="{made}" alt="{title}" width="{width}" height="{height}"  />{/exp:ce_img:pair}</a>
                                                      </div>

                                                </div>
                                                {/slideshow}

                                            </div><!-- .coda-slider -->

                                        </div><!-- .coda-slider-wrapper -->
                                                                        <div id="coda-nav-1" class="coda-nav">
                                        <ul>
                                        {slideshow}<li class="tab{count}"><a href="#{count}">{exp:ce_img:pair src="{url}" max="100" crop="yes"}<img src="{made}" alt="{title}" />{/exp:ce_img:pair}</a></li>{/slideshow}
                                               </ul>

                                        </div>

                 </div>
                                  {if:else}
                                    <div class="block">
                    <h4>{title}</h4>
                    <div class="block-content">
                        <ul class="news">
                            <li>

                                <div class="pic">
                                    <a href="{comment_url_title_auto_path}"><img src="{image}" alt="{title}" /></a>
                                </div>
                                <div class="details">
                                    <p>{content}</p>
                                    {if video_embed != ""}{video_embed}{/if}

                                </div>
                            </li>
                {/exp:channel:entries}
                 </ul>
                    <div class="clear"></div>
                </div>

                </div>

            </div>       {/if}      {/if}

```

# Answer
In the last line of your code you close with 2 if statements. Remove one.

If you still have issues, comment out blocks of code until error disappears.

Now, if you want some additional suggestions, you would be better off removing the if else wrapping the two channel entries tags. Use 2 if statements = and != for the segment instead, which will mean simple conditionals.

An embed would be better for each channel entry tag.

You may even be able to pass some variables to your embedded template so that you only end up using one channel entries tag, because they look very similar.
> 0 votes

# Answer
It's most likely because you're using a complex conditional withing a complex conditional and because you're code isn't closed properly. For complex conditionals (`if:else`) both conditions are parsed. So, try using two simple conditionals. With simple conditionals, only the true case is parsed. I'd highly recommend using the add-on Switchee as well.

```
  <div id="main">
    <div class="wrap">
      <div id="content">
        <div class="block">

          {if segment_2 == ""}
            <h4>NEWS</h4>
            <div class="block-content">
              <ul class="news">
              {exp:channel:entries channel="news" limit="6"  dynamic="off" orderby="date" sort="desc" paginate="bottom"}
                {paginate}
                  <p id="pagination">Page {current_page} of {total_pages} pages {pagination_links}</p>
                {/paginate}
                ...
              {/exp:channel:entries}
              </ul>
              <div class="clear"></div>
            </div> <!-- end .block-content -->
          {/if}

          {if segment_2 != ""}

            {exp:channel:entries channel="news" limit="1"  dynamic="off" orderby="date" url_title="{segment_2}"}

            {if slideshow}
            <h4 class="red">{title}</h4>
            <div class="block-content">
              {if "{content:has_excerpt}"}{content:extended}{if:else}{content}{/if}
            </div>
            <div class="coda-slider-wrapper">
              <div class="coda-slider preload" id="coda-slider-1">
                <div id="coda-nav-left-1" style="float:left;" class="top-arrow-nav">
                  <a href="#" title="Previous">< Previous</a>
                </div>
                <div id="coda-nav-right-1" style="float:right;" class="top-arrow-nav">
                  <a href="#" title="Next" >Next ></a>
                </div>
                {slideshow var_prefix="slide"}
                <div class="panel" id="panel{count}">
                  <div class="panel-wrapper">
                    {if slide:caption}<p>{slide:caption}</p>{/if}
                    <a class="xtrig" href="#{if slide:total_files == {count}}1{if:else}{exp:mx_calc expression="{count}+1"}{/if}" rel="coda-slider-1">{exp:ce_img:pair src="{slide:url}" width="715" height="536"}<img src="{made}" alt="{title}" width="{width}" height="{height}"  />{/exp:ce_img:pair}</a>
                  </div>
                </div>
                {/slideshow}
              </div> <!-- .coda-slider -->
            </div><!-- .coda-slider-wrapper -->
            <div id="coda-nav-1" class="coda-nav">
              <ul>
                {slideshow}<li class="tab{count}"><a href="#{count}">{exp:ce_img:pair src="{url}" max="100" crop="yes"}<img src="{made}" alt="{title}" />{/exp:ce_img:pair}</a></li>{/slideshow}
              </ul>
            </div> <!-- end .#coda-nav-1 -->
            {/if} <!-- end if slideshow -->

            {if !slideshow}
            <h4>{title}</h4>
            <div class="block-content">
              <ul class="news">
                <li>
                  <div class="pic">
                    <a href="{comment_url_title_auto_path}"><img src="{image}" alt="{title}" /></a>
                  </div>
                  <div class="details">
                    <p>{content}</p>
                    {if video_embed != ""}{video_embed}{/if}
                  </div>
                </li>
              </ul>
              <div class="clear"></div>
            </div> <!-- end .block-content -->
            {/if} <!-- end if !slideshow -->

            {exp:channel:entries}

          {/if} <!-- end if segment_2 != "" -->

        </div> <!-- end .block -->
      </div> <!-- end #content -->
    </div> <!-- end .wrap -->
  </div> <!-- end #main -->

```
> 0 votes

---
Tags: pagination
---


# Question
Title: Changing File Module's {file_size} variable into MB
Is there an easy way to change the File Module's {file\_size} variable from its default output of bytes, into megabytes?

Seems just slack not to provide a better user friendly output that what's on offer out of the box.

# Answer
It would be better to use any mathematics plugin which to calculate megabytes from bytes. You can use Simple Math plugin and use tag like

```
{exp:simple_math calculate="{file_size} / 1024"}

```
> 1 votes

---
Tags: files
---


# Question
Title: Using Low Search to ONLY search categories and Solspace Tags
I'd like to set up Low Search to **only** search category names and tags. I haven't been able to figure out a way to combine Low Search and Low Search Tag to just return results from category and tag names.

I have two category groups: Topics (group\_id="2") and Audiences (group\_id="11").

There are currently 282 tags set by the client using Solspace Tag 4.1.1. (group\_name="default") (group\_id="1")

Here's my most current attempt:

```
{exp:low_search:form
    collection="speakers"
    search_mode="all"
    result_page="search/results"}
{exp:tag:cloud tag_group_name="default"}

  <input type="text" class="text" name="keywords" id="textbox"  style="width:135px;" />

  {/exp:tag:cloud}
{/exp:low_search:form}

```

...and my results page

```
{exp:low_search:results
    tag_id="default"
}
  ...
{/exp:low_search:results}

```

I'm not sure if I should be nesting the low\_search and low\_search\_tag tag pairs within each other. Any help would be appreciated.

I'm using:

-- EE 2.5.5 -- Low Search 2.4.0 -- Solspace Tag 4.1.1

# Answer
> 0 votes
Low Search will always return **Entries**. The Results tag basically is the same as the `channel:entries` tag, but with added filters, including an advanced category filter and Solspace Tag filter, when used with Low Search Tag. It **does not** return the categories or tags themselves.

So, to filter by category and/or tags, follow the examples in the Low Search docs and Low Search Tag docs. The search results will only have entries that have the selected categories/tags assigned to them.

Also, note that Low Search Tag doesn't have tags itself, it just adds the ability to Low Search to filter by Solspace Tag, using these parameters.

Here's a crude example:

### Search Form

```
{exp:low_search:form
    result_page="search"
    query="{segment_2}"
    require_all="category"
}

    Select topic
    <select name="category[]">
        <option value="">All</option>
        {exp:channel:categories channel="speakers" category_group="2" style="linear"}
            <option value="{category_id}"{if category_id IN ({low_search_category})} selected="selected"{/if}>
                {category_name}
            </option>
        {/exp:channel:categories}
    </select>

    Select audience
    <select name="category[]">
        <option value="">All</option>
        {exp:channel:categories channel="speakers" category_group="11" style="linear"}
            <option value="{category_id}"{if category_id IN ({low_search_category})} selected="selected"{/if}>
                {category_name}
            </option>
        {/exp:channel:categories}
    </select>

    Select tag
    <select name="tag_id[]" multiple="multiple">
        {exp:tag:cloud tag_group_name="group1"}
            <option value="{tag_id}"{if tag_id IN ({low_search_tag_id})} selected="selected"{/if}>
                {tag}
            </option>
        {/exp:tag:cloud}
    </select>

    <button type="submit">Search!</button>

{/exp:low_search:form}

```

### Search Results

```
{exp:low_search:results
    query="{segment_2}"
    status="not closed"
    disable="member_data|category_fields"
}
    ...
{/exp:low_search:results}

```

In summary, this contains:

* A single select for Topic;
* A single select for Audience;
* A multiple select for Tag;
* `require_all="category"` will make sure only results with **both** selected categories are returned (so Topic A **and** Audience X, instead of Topic A **or** Audience X).
* The search results will contain entries that match **any** of the selected tags. To change that to **all**, add `tag_id` to the `require_all` parameter, thus: `require_all="category|tag_id"`.

If you want to be able to select multiple topics and audiences (so get results from Topic A, B, or C **and** Audience X, Y, or Z), use the Category Groups option.

---
Tags: search, low-search, solspace-tag
---


# Question
Title: How do you hook NewRelic monitoring into ExpressionEngine
I use NewRelic to monitor site performance, but since everything runs through index.php, the amount of data I get back regarding controller performance is limited and clumped together. How can I get more granular performance data?

# Answer
Does this help ?

**Instrumenting ExpressionEngine with New Relic ( and Tracelytics )** http://learningsomethingnewwith.wordpress.com/2012/03/04/instrumenting-expressionengine-with-tracelytics-and-new-relic/
> 2 votes

# Answer
FYI: EllisLab released New Relic monitoring in ExpressionEngine 2.7

http://ellislab.com/blog/entry/expressionengine-2.7.0-released (2nd sub head down)
> 1 votes

---
Tags: performance, newrelic
---


# Question
Title: EXP template inside another EXP template dosent work
I have install a plugin to get channels. And that was i have used in template

```
{exp:getchannels}
{channel_name}
{/exp:getchannels}

```

From this I got the result i.e. list of channels. thats ok. working good. and then I need to execute a query like this

```
{exp:query sql="Select CONCAT('field_id_',field_id) 'field_id', field_name, BASE64_DECODE(field_settings) 'field_settings', field_label
     from exp_channel_fields f join exp_channels c on c.field_group = f.group_id where c.channel_name = 'programme' order by field_order"}
     <br/>{field_name}<br/>
{/exp:query}

```

from this I got the result of particular channel that is "Programme"

Now my query is that, I would like to use that `query EXP` inside the `getchannel EXP`, like below mentioned

```
{exp:getchannels}
{channel_name}
{exp:query sql="Select CONCAT('field_id_',field_id) 'field_id', field_name, BASE64_DECODE(field_settings) 'field_settings', field_label
     from exp_channel_fields f join exp_channels c on c.field_group = f.group_id where c.channel_name = '{channel_name}' order by field_order"}
     <br/>{field_name}<br/>
{/exp:query}
{/exp:getchannels}

```

Now problem is that, that `query EXP` returns blank when i execute that inside `getchannel EXP`. Here I would like to get the fields of each channel what channels are getting by `getchannel EXP`, yes same like `FOREACH LOOP`.

If i `echo` this query and `execute` that inside `PHPMYADMIN` it returns result exactly what i want.

I think there is something wrong with that. Don't getting the idea whats wrong in that. Can Anybody help me to solve that.? I stuck at this point.

Thanks in Advance.

# Answer
> 1 votes
Your issue is you cant use php inside the query tag sql. If you dont believe me, look at the source code for query module. From memory its in system/module/query. Remove this:

`BASE64_DECODE(field_settings) 'field_settings', field_label`

Now this works:

`{exp:query sql="Select CONCAT('field_id_',field_id) 'field_id', field_name, c.channel_name {!--BASE64_DECODE(field_settings) 'field_settings', field_label--}
 from exp_channel_fields f join exp_channels c on c.field_group = f.group_id order by c.channel_name asc, f.field_order asc"}
 {channel_name}
{field_id}, {field_name}
{/exp:query}`

But i see you want to group by channel name, so wrap it with your {exp:getchannels} tag like you did in your example (sorry, using my ipad...takes too long to show code). That should work.

Update: If exp:getchannels is a plugin it wont work. Modules get parsed before plugins parse order. So to change to

`{exp:getchannels parse="inward"}`

However, you still need to decode the field settings, so your best solution is to create a plugin to run the query, then loop through the output and decode the field settings row.

You can also run queries here. And check db here

---
Tags: channel, query, fields
---


title: Upload only field

text:
# Question
Title: Upload only field
Is there a setting for the file-fieldtype or a third-party fieldtype that allows only to upload a file (and NOT browse existing ones).

The goal is that certain member groups are only supposed to add files.

# Answer
Channel Files will probably do what you're looking to do. The "Limit Stored Files by Author" setting is probably what you're looking for, here's a screenshot of the fieldtype settings screen: http://www.devdemon.com/images/products/30/fieldtype.jpg

You can buy it here: http://devot-ee.com/add-ons/channel-files
> 1 votes

# Answer
I just remembered the Safecracker File fieldtype which perfectly fits the bill.

That said, I just read it has been removed in 2.7 ...
> 0 votes

---
Tags: file-uploads, fieldtype, uploads
---


# Question
Title: Combining the zoo visitor {member_firstname} {member_lastname} field automagically into one field {member_name}
Zoo Visitor has an elegant setting that makes {screen\_name} very nice:

> Set screen\_name as a combination of the following fields

The default setting is {member\_firstname} {member\_lastname}. Perfect.

However, in Exp-resso Store, the 'billing\_name' field is one field, so i'd like to automatically combine both fields to another field {member\_name} which i can map to the {billing\_name} field.

How can I combine to custom fields into one other field without the user ever noticing?

*I'm not too fond on using a hidden field and some javascript in my registration process.*

# Answer
This is how I worked around my problem:

1. I created the field {member\_name}.
2. I set the field type to Select Dropdown with only one option: {screen\_name}.
3. I mapped the {member\_name} field (with contents: {screen\_name}) to {billing\_name}.
4. Zoo Visitor automatically changes the contents of {screen\_name} to {member\_firstname} {member\_lastname}.

I'm not sure if this will *always* work, but I'm pretty sure it's a nice solution.
> 3 votes

# Answer
The only other way to do with without JavaScript would be to use an extension. Basically, hook into the POST data and programmatically update the entry/field with first and last name values. Now what hook you use and the logic required is outside the scope of this answer. But logically speaking, use an extension to update that field programmatically.

If it were me, I would go the JS route first. If you find that is problematic, I would then write to the extension - simply for the time factor. Seems like a lot of work to write an extension when JS might work fine.
> 6 votes

# Answer
This worked like a charm for me:

```
<input
 type="text"
 name="billing_name"
 value="{visitor:global:member_firstname} {visitor:global:member_lastname}" />

```

I used that to replace the standard Expresso Store tag:

```
{field:billing_name}

```

Technically speaking, you're still not getting the nice, one-to-one mapping relationship between Zoo Visitor and Expresso Store but it certainly works to "fool" Expresso Store into automatically receiving the first and last name fields from Zoo Visitor.
> 0 votes

---
Tags: expresso-store, custom-fields, zoo-visitor
---


# Question
Title: Is Playa as slow as built in Relationships with 1000s of entries?
I'm trying to relate multiple entries in a database with about 2,500 total entries in one channel. It takes a minute to load the full list in the control panel for each entry -- which is unacceptable for doing many of these each day. I know I can limit the entries, but I need to relate to previous entries throughout my database.

What I'm wondering is if Playa is any better at this? For those of you using it to relate to at least 2,000 entires in a channel, do you have to wait 60 seconds+ for the list to load? (And yes, I'm on a very fast Internet connection -- this appears to be a browser/server issue.) If it's much faster, I'll buy it ASAP!

# Answer
Do you mean that a single entry could have a single entry relating itself to over 2,000 other entries, or just that there are 2,000+ other entries to choose from?

If the latter, the answer is Yes, Playa is quite capable of dealing with large numbers of entries. Simply set a Limit on the Playa field to something like 100 entries, and then use the Search bar to get at whatever isn't immediately visible.
> 4 votes

# Answer
What version of ee are you using?

If it is below 2.6 you will see two additional columns in the exp\_relationships table. These are rel\_data and reverse\_rel\_data columns.

If these columns exist, thats your problem. In other words, these columns cache the content of the related entry.

Solution, upgrade ee as the new relationships field type looks to have been redesigned like playa, and i suggest it is much more efficient.
> 1 votes

---
Tags: playa, relationships, performance
---


# Question
Title: Is there a good control panel add-on that provides more robust member search functionality?
We have a client's site that has a handful of custom member profile fields, one of them being used for a street address. This particular client would like to perform a keyword search on that address but there's no way to do that from EE. I know we can build a custom search form on the front-end using Solspace User but I was hoping for a control panel add-on that would provide similar functionality.

# Answer
> 1 votes
As far as I know there's nothing native or by way of an addon that provides a better search facility for custom member fields from the control panel. If you specifically wanted this then I'd go with either Profile:Edit or Zoo Visitor which brings your Member data into regular channels for searching, filtering, and sorting via the Edit screen. They make it much easier when dealing with front-end templates and custom member fields too.

# Answer
> 1 votes
I am not aware of any addons that offer keyword search of member data.

I'd suggest building this in a normal EE template with jQuery. Protect the page with a conditional to only allow access to the member groups you want to view it and create a quick link to the page from inside the EE control panel.

Set up an EE template to pull all the member data into a table using EE tags or the query module and use a jQuery plugin for the search/filtering... **DataTables** is a free jQuery plugin that will allow searching/filtering and pagination.

# Answer
> 0 votes
I've had some success using a standard `GET` form and inserting the search term with PHP into a `{exp:query}` tag on the results template. I then pass the resulting member IDs to Freemember and output the member data with it. You'll need to have access to your SQL database to identify the ID names of your custom member fields.

**NB: I don't know whether this method is at risk for SQL injection.**

The search form is straightforward:

```
<form method="get" action="/search">
    <label for="s">Search by Member Screen Name, Affiliation, or Maiden Name</label> <br />
    <input type="search" name="s" id="s" /> <input type="submit" value="Search" />
</form>

```

Now for the search results template. Suppose you've created two custom member fields called Member Affiliation and Member Maiden Name, and you want a single search form that returns matches to those two fields as well as Screen Name. Open up `exp_member_fields` in PHPmyAdmin or Sequel Pro, look for those fields, and note the `m_field_id` associated with them. Suppose you see they have IDs `10` and `11`.

Now create a search results template (`search/index`). Set *Allow PHP* to `Yes` and *PHP Parsing Stage* to **Input**. Note that Input parsing is less common then Output and it can cause problems if you're using PHP in other ways on the same template.

```
<?php
    // retrieve input, if any
    $s =isset($_GET["s"]) ? $_GET["s"] : null;
    ?>

    <h2>Search Results for <em><?php echo $s; ?></em>.</h2>

    {!--
    Let's search these fields:
    screen_name:        screen_name (it's already part of exp_members)
    member_affil:       m_field_id_10
    member_maiden:      m_field_id_11
     --}

    {exp:query limit="100" sql="
       SELECT * FROM exp_member_data
       JOIN exp_members ON exp_members.member_id = exp_member_data.member_id
       WHERE  (
            screen_name LIKE '%<?php echo $s;?>%')
            OR (m_field_id_10 LIKE '%<?php echo $s;?>%')
            OR (m_field_id_11 LIKE '%<?php echo $s;?>%')
            )
            ORDER BY screen_name
            "}

                {embed="search/_member" the_member_id="{member_id}"}

             {/exp:query}

```

Finally, the embedded template (`search/_member`) looks like this:

```
    {exp:freemember:members member_id="{embed:the_member_id}"}
        <h2>{screen_name}</h2>
        Member Affiliation: {member_affil}
        Member Maiden Name: {member_maiden}

        etc...

    {/exp:freemember:members}

```

---
Tags: members, search, member-details
---


title: "no input file specified" - .htaccess

text:
# Question
Title: "no input file specified" - .htaccess
I'm in the process of migrating my sites to Media Temple.

I need to change the htaccess file and add a '?' to successfully remove the 'index.php' from the URL. Without it I get "No input file specified"

This works.

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

```

But i'm also running CE Cache, static caching.

How would I edit the static cache handler to do the same?

```
#------------------- remove trailing slash -------------------
RewriteCond %{REQUEST_URI} !^/system [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)/$ /$1 [R=301,L,QSA]

#------------------- index.php -------------------
#strip index.php from the URL if that is all that is given
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteRule ^(([^/]+/)*)index\.php$ http://%{HTTP_HOST}/ [R=301,NS,L,QSA]
#strip index.php/* from the URL
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php/ [NC]
RewriteRule ^index\.php/(.+) http://%{HTTP_HOST}/$1 [R=301,L,QSA]

#------------------- CE Cache Static Driver -------------------
RewriteCond %{REQUEST_URI} !^/system [NC]
RewriteCond %{QUERY_STRING} !ACT|URL [NC]
RewriteCond %{REQUEST_METHOD} !=POST [NC]
RewriteCond %{DOCUMENT_ROOT}/static/ce_cache/242d7a/static%{REQUEST_URI}/index\.html -f [NC]
RewriteRule (.*) /_static_cache_handler.php%{REQUEST_URI}/index\.html [L,QSA]

#------------------- EE -------------------
#rewrite all non-image/js/css urls back to index.php if they are not files or directories
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]

```

# Answer
This generally has to do with PHP being connected to Apache via FastCGI, rather than mod\_php. When this is the case, an extra ? is needed in the rewrites to EE's index.php:

From

```
 RewriteRule ^(.*)$ /index.php/$1 [L,QSA]

```

To

```
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]

```
> 8 votes

# Answer
This did it:

```
<IfModule mod_rewrite.c>
    RewriteEngine On

    #------------------- remove trailing slash -------------------
    RewriteCond %{REQUEST_URI} !^/system [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]

    #------------------- index.php -------------------
    #strip index.php from the URL if that is all that is given
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
    RewriteRule ^(([^/]+/)*)index\.php$ http://%{HTTP_HOST}/ [R=301,NS,L,QSA]
    #strip index.php/* from the URL
    RewriteCond %{THE_REQUEST} ^[^/]*/index\.php/ [NC]
    RewriteRule ^index\.php/(.+) http://%{HTTP_HOST}/$1 [R=301,L,QSA]

    #------------------- CE Cache Static Driver -------------------
    RewriteCond %{REQUEST_URI} !^/system [NC]
    RewriteCond %{QUERY_STRING} !ACT|URL [NC]
    RewriteCond %{REQUEST_METHOD} !=POST [NC]
    RewriteCond %{DOCUMENT_ROOT}/static/ce_cache/242d7a/static%{REQUEST_URI}/index\.html -f [NC]
    RewriteRule (.*) /_static_cache_handler.php?%{REQUEST_URI}/index\.html [L,QSA]

    #------------------- EE -------------------
    #rewrite all non-image/js/css urls back to index.php if they are not files or directories
    RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]

</IfModule>

```
> 0 votes

# Answer
I also needed to change "system" to the folder that I have renamed for my EE install. That fixed all issues.
> 0 votes

---
Tags: htaccess, ce-cache
---


title: simple relationship question

text:
# Question
Title: simple relationship question
I have one channel for workshops and one for events. each workshop can have multiple events but each event can only belong to one workshop. workshops are rarely added/edited. but new events are added frequently.

so my set-up is as follows:

```
workshops
    title                           Text Input
    description                     Text Area

events
    title                           Text Input
    date-and-time                   Date
    belongs-to-workshop             Relationship (to workshops, single)

```

now I have a template where I want to show all workshops and under each workshop I want to list related events. one easy way (so far) seems to be another field in the workshops channel: some field like "related events" (a mulitple-relationship pointing to events channel). but that means the admin would have to edit the workshop entry each time they add a new event. I'd like to make it easy on the user and just let them add events and link the event to a workshop by using the "belongs-to-workshop" drop down.

question: how could I access the events in my 'workshops' template which looks like this:

```
{exp:channel:entries channel="workshops"}
<div class="workshop">
    {title}, {description}
    Related Events: {???}
</div>
{/exp:channel:entries}

```

does the "workshop" entry not know which events are related? I suppose that's what the old "reverse related entries" tag was for?

any help appreciated.

# Answer
> 0 votes
See documentation here

```
{exp:channel:entries channel="workshops"}
  {parents field="relationship_field"}
    {parents:title} - {parents:field1} - {parents:field2}
  {/parents}
{/exp:channel:entries}

```

---
Tags: ee2
---


# Question
Title: Relationships/Grid Fieldtype can replace Playa/Matrix?
I am currently using Playa and Matrix to manage multiple relationships and a gallery of images.

I am at 2.5.5 and contemplating upgrading to 2.7. I looked at the changelog and I saw the new Relationship fieldtype that support multiple relationships and the Grid fieldtype.

Are these new fieldtypes robust enough to replace those?

**UPDATE**: I think I might have been too general/vague in my description. To clear things up, these are 3 features that I need that I am not sure is doable in Relationship/Grid

* A radio button that is a "is\_default" field. This means that it should be aware of the other radio buttons in other rows in that there should only be one checked radio button at all times
* Pagination support for Grid
* Multiple relationships field inside Grid. I am aware that the new Relationship fieldtype supports multiple relationships now but the question is if it is available inside Grid

# Answer
If by "robust enough" you mean do they have basically the same features, yes.

I've used EE's Relationships without any issues. I love Grid's search:column\_name feature. That's a step up from Matrix. However, since it is brand new, it does not work with as many third party fieldtypes as Matrix. I'm sure that will change in the next 2-3 months. Depending on the fieldtypes you need for your image gallery, Grid will get the job done.
> 3 votes

# Answer
On top of better compatibility with third party fieldtypes, Playa and Matrix also have, IMHO, better and more polished UI. For example, if your client needs to search / filter through loads of entries, Playa is better suited.

As always, what you set on using depends on the project requirements.

**EDIT:**

* Is default: not sure I get that one. To my knowledge, what you describe is not possible to automate. I just make the "default" picture (if that's what you are talking about) is always the first one. Since rows can be reordered easily, clients do get it.
* Pagination inside grid: ok with Matrix (prev\_row / next\_row) as well as with native grid (prefix:prev\_row / prefix:next\_row)
* Relationships inside grid: available w/ Matrix and Playa and natively too

**EDIT 2:**

Functionality-wise, these fieldtypes are pretty similar (although I haven't used grid in production yet). I am a big fan of the care and thought about usability that has been put into Matrix and Playa. The latter particularly has had nothing but praise from my users. Here is a video compairing both options on EE insider
> 2 votes

---
Tags: matrix, playa, relationships, grid, 2.7.0
---


# Question
Title: "Time Ago" addon that has multilanguage support
I am using this addon to show time in a "time ago" format. The problem with this one is that it doesn't seem to support multilanguage.

Is there an add-on or a PHP solution that supports this kind of feature?

# Answer
> 1 votes
I think, you would like to show the Date (like day, month name) in different languages. Right? If you are using language pack for multi-language then you can change those into language file "system\expressionengine\language\english\core\_lang.php". This is for English, you can do same for other language.

# Answer
> 0 votes
Time / date values seem to be hardcoded in English in the plugin code.

A few things you can try:

1. Ping the dev on github or via email (look at the source code)
2. As a temporary solution you could use Low Replace (or something similar) to replace some text in English by its equivalent in whatever language you need.

Code:

```
{exp:low_replace find="on|1 day ago|([0-9]+) days ago" replace="le|il y a 1 jour|il y a $1 jours" multiple="yes" regex="yes"}
    {exp:nice_time date="{entry_date}" format="%d-%m-%Y"}
{/exp:low_replace}

```

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


# Question
Title: If logged in statement failing - template not parsing properly
I have an Expresso:Store site and I am using the following conditionals in the header:

```
{exp:store:cart}
{if no_items}
    <a href="{path='store/checkout'}">Your bag is empty</a>

        <div class="details">
            {if logged_in}
                <br /><a href="{path='store/my_orders'}">My Orders</a>
                <!-- template parsing fails -->
            {if:else}
                <br /><a href="{path='account/login'}">Login</a>
            {/if}
         </div>
    {/if}

<a href="{path='store/checkout'}">My Shopping Bag ({order_qty})</a>
    <div class="details">
         <span class="price">{order_subtotal}</span><a href="{path='store/checkout'}">Checkout</a>
     {if logged_in}
         <br /><a href="{path='store/my_orders'}">My Orders</a>
     {if:else}
         <br /><a href="{path='account/login'}">Login</a>
     {/if}
     </div>
{/exp:store:cart}

```

When I am logged in, the template parses fine and everything works.

If I am NOT logged in, the template parses up to the commented line and the header template fails to output anything after that line, breaking the remaining page layout.

It's as if it just stops after that line, but I can't work out what I have done wrong, there are no template errors I can see in the EE template editor.

# Answer
> 0 votes
Perhaps it's to do with parse order? From my understanding, the {if:else} conditional (particularly of the logged\_in variety) is counted as an advanced conditional, so gets parsed later than modules, such as the Expresso:store.

This is just guessing, but perhaps when parsing exp:store:cart, it's interpreting the {if:else} on line 9 as being part of the {if no\_items} conditional, rather than the {if logged\_in}.

Hope that helps

# Answer
> 2 votes
Try this instead:

```
 {if logged_in}
     <br /><a href="{path='store/my_orders'}">My Orders</a>
 {/if}
 {if logged_out}
     <br /><a href="{path='account/login'}">Login</a>
 {/if}

```

Not sure if it's an EE version thing, but {if:else} never used to work for me on older EE versions, but does with the latest. Either that or it's where it's used (EE introduced new conditional parsing rules with a more recent update), so the {if:else} may work in channel:entries, but not outside. Just theoretical.

# Answer
> 0 votes
I have worked out that the issue is something to do with nesting {if logged\_in} within the {if no\_items} loop.

The code is all working fine without the {if} statement in the expresso:store {no\_items} - a bit of reworking the code to not need any nested loops worked much better.

I can't explain the issue, but it's resolved my problem.

---
Tags: members, conditionals, template-scripting
---


# Question
Title: How to stop Matrix NSM TinyMCE field from converting HTML tags to entities
I have a matrix with a text field and a NSM TinyMCE field. For some reason the NSM TinyMCE field keeps converting HTML tags to entities. So I get things like:

\<p\><p>&lt;p&gt;&amp;lt;p&amp;gt;&

Everytime I save the entry I get a new set of \<p\>&

I checked NSM TinyMCE field on its own and that works fine. No entities conversion.

I checked the channel for "Default HTML formatting in channel entries" and it's set to "Allow all HTML".

I also tried adding entity\_encoding : "raw" in my TinyMCE config file.

My EE2 is v2.5.3 Matrix 2.5.2

What am I doing wrong?

# Answer
I saw this on another site that used a different CMS, it turned out to be an issue with magic\_quotes on the server - we disabled magic-quotes and TinyMCE worked fine after that.
> 1 votes

# Answer
you can fix this by going to

`\system\expressionengine\third_party\nsm_tiny_mce\ft.nsm_tiny_mce.php`

```
return form_textarea(array(
   'name' => $this->cell_name,
   'id' => $this->col_id,
   'value' => $data,
   'rows' => ' ',
   'style' => "height: {$this->settings['height']}px"
  ));

```

**Replace this with**

```
return ' <textarea name="'.$this->cell_name.'" id="'.$this->col_id.'" style="height:'.$this->settings['height'].'px">'.$data.'< /textarea>';

```
> 0 votes

---
Tags: ee2, matrix, html-entities
---