# Question
Title: Foreign Languages Displayed as HTML Entities
So we've just completed a transition from EE1 to EE2 for a client with a very large database of publications. Some of the publications are available in multiple languages, with Chinese, Korean, and Vietnamese being some of the more popular translated languages, behind Spanish.

On the front-end, the languages are displaying fine, but in the Control Panel they are displaying as HTML entities. Now database wise, this is the same. All the languages were always stored as html entities in MySQL, but before, when the record was pulled up in the control panel, it was readable as that languages.

This is a Korean Publication in EE1.

This is the same Korean Publication in EE2

Now if I go back from the Control Panel and re-enter the data as Chinese, Korean, or Vietnamese the data then displays in that language.

Obviously, we don't want them to have to re-enter hundreds or more publications just to view the text in the proper language, but I can't seem to figure out why EE2 isn't converting the html entities back into the specified languages.

The database is set for UTF-8, charset is also UTF-8, language is English. We didn't have any foreign language packs installed, since the translations only apply to the documents, not the control panel. We still have an EE1 version of the database with Control Panel ONLY access and can compare the databases, and with the exception of table name changes, they look the same.

I'd assume this is or at least was a setting somewhere, but not in the normal config.php settings. Does anyone know where or what I can troubleshoot to get this conversion working properly again?

Obviously, the text needs to be readable for the client to edit and update the publications.

# Answer
I thought I'd provide the response that Ellis Lab gave me for this issue, for others who may need it in the future. Unfortunately, it doesn't solve my issue, since rolling back the database at this point really can't be done. The client gets hundreds of new entries into EE2 every couple of days and its been almost a month since the transition. That said here are the details from Ellis Lab…

> The html entities are the result of double-encoded data. As part of the upgrade process, ExpressionEngine converts your database to UTF-8. However, if any data is already set to UTF-8, it will be re-encoded and you will see the bizarre characters.
>
> Essentially, you need to roll back to the pre-upgrade state. Once you are there follow these steps.
>
> Edit out this bit in `/system/expressionengine/installer/updates/ud_200.php`
>
> Find: `foreach ($tables as $table) { $progress = "Converting Database Table {$table}: %s"; $count = $this->EE->db->count_all($table); $offset = 0;`
>
> It should be around line 415. Now comment out the code beginning with:

```
/*
if ($count > 0) //around line 421

... all the way through ...
$offset = $offset + $batch; // around line 465
}
*/

```

> Then upload this to your server and perform the upgrade per the instructions.
>
> What this will do is convert your tables to UTF-8 collation but not the data in those tables. This will be safe through future updates too. This simple edit keeps the installer from double-encoding the data.

So now that I know the process or issue is one of double encoding, I'm trying to find a method that will decode content of a query. Considering the size of the clients database (over 45,000 records), the Asian language records make up a very small percentage (around 300 records).

Decoding them one by one has been relatively easy, but is obviously time consuming. A scripted decode solution would be great. I've tried with MySQL alter statements

```
ALTER TABLE exp_weblog_data MODIFY field_id_1 text character set binary;
ALTER TABLE exp_weblog_data MODIFY field_id_1 text character set utf8;

```

as well as testing against some conversion statements, such as

```
SELECT field_id_1
CONVERT(CAST(field_id_1 AS BINARY) USING utf8)
FROM exp_channel_data
WHERE channel_id="6";

```

I tried the ALTER on the old database table, to see if it would work, since the data seems to be encode in that one as well (though displays fine in the control panel). I didn't want to deal with any unexpected repercussions of ALTERing the live database.

I did find a few great resources on MySQL conversion issues, which may help others in the future:

Nic Jansma wrote up an awesome article on various conversion issues, how to test, and how to convert, see: http://nicj.net/mysql-converting-an-incorrect-latin1-column-to-utf8/

Mattias Gunneras got me started on the testing of ALTER table commands, which may work for many, though didn't for me, see: http://www.bothernomore.com/2008/12/16/character-encoding-hell/

The GeekGuide provided some more insight into how to properly use CONVERT, CAST, and BINARY, see: http://www.geeksengine.com/database/single-row-functions/conversion-functions.php

Ultimately, it maybe quicker for me to convert the records by hand, just copying and pasting from the old control panel to the new control panel. But since I expect this maybe an issue again in the future, I'm still working on finding a scripted process for dealing with the issue.

My goal is to figure out how to run a UTF8 Decode (like: http://www.utf8converter.com ) on select records in a database, store in a temporary table, then UPDATE the database with the converted data.

**Updated. 12/17/2012.** Ellis Lab wrote a quick extension, 'EllisLab High ASCII Decode' that converts for the control panel, making Asian Languages fully readable and editable. Apparently a leftover setting from EE 1 did an 'auto\_convert\_high\_ascii' and that was the issue. So this is now totally resolved.
> 3 votes

# Answer
Have you tried changing the custom field "Default Text Formatting" to 'None' in the custom field settings?
> 1 votes

---
Tags: control-panel, ee1, multi-language, multilingual, html-entities
---


# Question
Title: Getting the Blank / White page, but only for one channel
I have a channel called "Sub" that's essentially a catch-all for generic interior pages. All other channels (approximately 6) are loading fine, but the "sub" channel won't load anything in any template. It's not a template problem as I've tried it in multiple.

Here's the code I currently have in my template:

```
{embed="_includes/html_head"}
    Hello!
    {exp:channel:entries channel="sub"}
    <body id="interior" class="{categories limit='1'}{category_url_title}{/categories}">
        {embed="embeds/interior_supernav"}
        <div id="site-wrapper">
            <header id="main-header">
                <div id="site-header">
                    {embed="embeds/header_opening_tag" width="400" height="268"}
                        <h1>{exp:low_variables:parse var='full_organization_name'}</h1>
                        <nav id="main-navigation">
                            <h2><abbr title="College of Environmental Design">CED</abbr> Menu</h2>
                            <div class="groups">
                                {exp:structure:nav start_from="/" show_depth="1" exclude="1" css_id="none" css_class="site" status="open|featured"}
                                {exp:structure:nav start_from="/academics" show_depth="1" css_id="none" css_class="departments" include="19|143|21"}
                            </div>
                        </nav>
                    </div>
                </div>
                <div id="interior-header">
                    {embed="embeds/interior_header_opening_tag"}
                        <h2>
                            {if section_title == ""}
                            {if {structure:page:entry_id} == {structure:top:entry_id}}
                            {exp:low_variables:parse var='full_organization_name'}
                            {if:else}
                            {structure:top:title}
                            {/if}
                            {if:else}
                            {section_title}
                            {/if}
                        </h2>
                    </div>
                </div>
            </header>
            <div id="interior-wrapper" {if sub_related_content == ""}class="no-related-content"{/if}>
                <nav id="interior-navigation">
                    {exp:structure:nav start_from="{segment_1}" show_depth="2" show_overview="yes" rename_overview="title"}
                </nav>
                <section id="interior-content">
                    <article>
                        <header>
                            <h1>{title}</h1>
                            {if subhead}<h2>{subhead}</h2>{/if}
                        </header>
                        <div class="article-content">
                            {sub_content}
                        </div>
                    </article>
                </section>
                <section id="related-content">
                    {sub_related_content status="open|featured"}
                    {if "{channel_short_name}" == "events"}
                    {events_syndication_details}
                    <article class="minor-article {categories limit='1'}{category_url_title}{/categories}">
                        <a href="{page_url}" class="url">
                            {if entry_image}
                            <figure>
                                {exp:ce_img:pair src="{entry_image}" max="400"}
                                <img src="{made}">
                                {/exp:ce_img:pair}
                            </figure>
                            {/if}
                            <header>
                                <h3><span class="tag-name">{categories limit="1"}{category_url_title}{/categories}</span></h3>
                                <h2>{title}</h2>
                            </header>
                            <p class="description">{entry_excerpt}</p>
                        </a>
                    </article>
                    {/events_syndication_details}
                    {/sub_related_content}
                </section>
            </div>
        </div>

        {embed="_includes/footer"}
        {embed="_includes/body_close"}
    </body>
    {/exp:channel:entries}
    Goodbye!
{embed="_includes/html_foot"}

```

I get nothing between the "Hello!" and "Goodbye!". In fact if I remove everything but that and the entries tag pair I still get nothing:

```
{embed="_includes/html_head"}
    Hello!
    {exp:channel:entries channel="sub"}
    There?
    {/exp:channel:entries}
    Goodbye!
{embed="_includes/html_foot"}

```

"There?" doesn't show.

# Answer
I'm a fool. It was because I had the status set to "Featured" but wasn't looking for that. Updated to `{exp:channel:entries channel="sub" status="open|featured"}` and all is good in the world.

Sorry to waste anyone's time.
> 3 votes

---
Tags: channel, blank-screen
---


# Question
Title: Replacing Native Relationships with Playa - Update 300 some entries at once
I’m trying to switch a site from the Multi Relationships add-on to Playa, the Multi Relationships add-on is just too limiting and Playa would solve the problems.

The trouble is, I have over 300 hundred entries in a particular Channel, and apparently due to the fact that this channel was using Multi Relationships and not native relationships, I can't use Playa’s converter.

For the particular application, it's my church's website, and for each sermon we post, I associate the sermon with a Channel entry for the speaker. Most of the sermons are from my pastor. It seems like I should be able to submit a query that will update the Playa field for each entry to be associated with the Pastor’s Channel entry, and then manually go in a change the few sermon’s that were preached by someone else, but I can’t figure it out. So far, nothing. Any help on how to run that query would be appreciated, queries are my Kryptonite.

# Answer
Remember to backup your database before tackling any serious SQL updated statement.

What I'd do is assign one of the sermons manually and see what your Playa field gets set as inside exp\_channel\_data table.

Then run something like

```
update exp_channel_data
set your_playa_field_id='value you noted above'
where exp_channel_data.channel_id='sermon_channel_id'

```

What I'm not sure is whether the Playa relationships table would need to be updated as well. I think it would but you would need to insert new records to that table.
> 1 votes

---
Tags: playa, relationships
---


# Question
Title: How to run a php script silently (like a cron job) from an EE template
I've got a PHP script that updates an entry's status depending on certain criteria being met. I was planning on running this script as a cron job on my web server every hour.

It'd also be nice if I could run it on certain templates on the website too (like on a success/confirmation page after an entry was submitted), so that entries can be updated right away should they need to be.

How would I go about running this script silently from a template though, without it outputting anything to screen? I almost want to 'ping the cron job' (pardon the lack of technical terms here!) from the EE template. It's not something I've done before so I'd appreciate any advice on the best way of going about this, thanks.

Edit:

As a final follow-up, here's the code I ended up using inside my EE template. I followed Anna's first recommendation below and used the PHP exec() function, and I ran this PHP using CE String's php method:

```
{exp:ce_str:ing php}
  <?php
    exec("php path/to/my/php/script.php > /dev/null &");
  ?>
{/exp:ce_str:ing}

```

# Answer
> 6 votes
Here are 3 quick/easy options:

USING PHP
This question on Stack Overflow sounds like what you're wanting to do:

**Use php to trigger another php script, then ignore**

---

USING CURL
Another method would be to use CURL. Here's a **Stack Overflow answer** with an example.

---

USING JAVASCRIPT
Another method is using JS/jQuery. **This answer on Stack Overflow** shows example code:

# Answer
> 7 votes
Sorry for the super simple answer, but I would just abstract your logic so you could execute the same function with the cron job as you would with the template tag. By creating an EE module you could create an ACT id to execute the cron job script, and use the plugin portion for the template. A common library would be the two that links it all together. Pretty simple really.

*Note, I don't ever put PHP in templates. This is one black and white rule I don't think ever needs to be broken provided you have the skill to write a plugin. IMO, there is no proper instance where PHP in the template is better than a plugin.*

---
Tags: templates, php
---


# Question
Title: How can I disallow Javascript and CSS entered into WYGWAM fields?
I have a client that has a nasty habit of entering `<style>` and `<script>` tags and `style=""` attributes to WYGWAM content and I need to be able to cut them off at the pass. They should hire me to do that for them!

So what I need is to delete anything entered in a WYGWAM field that matches these tags and attributes.

Possible?

# Answer
*NB This P&T support thread seems to suggest that CKEditor (which is the editor WYGWAM is based should automatically strip `<script>` tags, so might be worth checking your `themes/third_party/wygwam/lib/ckeditor/config.js` file and asking on their Get Satisfaction if that isn't the case for you.*

That aside. even if you can do this in CKEditor, my attitude would be that this isn't something you can do robustly in JavaScript, so ideally we need to either fix this on save (with an extension) on on output in your templates (with a plugin).

### With an extension:

I'm not aware of an existing extension that will do this, but if you have the PHP chops you could probably hook something up to `entry_submission_start`, and then use `$this->EE->security->xss_clean()` or similar to strip script tags (though this may not be the best option for your application).

### With a plugin:

Generally it's always safer to whitelist tags rather than blacklist the one's you don't want to allow, so one (easy to implement) option would to strip tags on output using a plugin like SuperGeekery Tag Stripper or Hacksaw:

```
{exp:eehive_hacksaw words="100" allow="<p><b>"}
  {your_content}
{/exp:eehive_hacksaw}

```

If you go down this route I'd tend to use a snippet to share my permitted tags across templates:

```
{exp:eehive_hacksaw words="100" allow="{sn_permitted_tags}"}
  {your_content}
{/exp:eehive_hacksaw}

```
> 3 votes

---
Tags: javascript, tags, css, wygwam, richtext
---


title: How to set background color for Wyvern

text:
# Question
Title: How to set background color for Wyvern
I'm trying Wyvern due to easier Typekit integration.

I have a simple CSS file linked, but oddly, I can't seem to set field's BG color.

When I load a publish layout, I see the BG color I have set, but once I enter the Wyvern field it switches to a near-white.

The CSS in question from my linked file:

```
body{margin: 10px; background:#2b2b2b;color:#ffffff;font:14px/1.256em "freight-sans-pro",sans-serif;padding:0;}

```

# Answer
Adding my comments as an answer as asked by Ultrabob:

Adding !important to the style that's not working can fix this:

```
body { background:#2b2b2b !important; }

```

As Ultrabob said, if this works, it means that there was another style at equal or greater specificity which was overriding the style you set. Using important! says that the style is important and should take precedence over other rules.
> 1 votes

# Answer
If you have are seeing your styles show up until you enter the field I would look for a more specific style for the field itself. That could be a style targeted at input or at :focus, most probably something that includes :focus because you say the background color is correct until you click into the field. body is a VERY nonspecific selector. That means that eny selector that gets more specific will override it.

If you don't see that a style reason for this, maybe look at the javascript to see if there are any events that change the background color when the fields come into focus?

I thing the developer tools in your browser are likely to be your friend on this one.
> 1 votes

---
Tags: wyvern
---


# Question
Title: How do I prevent encoding of URL in Live Look?
Something has happened to the Live Look links in the entries within my control panel. After submitting a new article, the Live Link (link to a preview of my article) looks like this:

https://mysite.com/?URL=https%3A%2F%2Fmysite.com%2Ftemplate\_group%2Flivelook%2F185

instead of like this:

https://mysite.com/?URL=https://mysite.com/template\_group/livelook/185

This is new. I'm not sure why it's now happening. I'm on EE 2.5.3.

Any thoughts on how to get the normal link back?

---

Additional info:

This problem is not only happening for me with live sites. If I install a completely new EE 2.5.3 in MAMP with no extensions I still see this problem.

# Answer
> 3 votes
Thanks to both Dom Stubbs & Media Girl. You spurred me to deeper investigation and I've got a solution working for me.

It looks like when the 2.5.3 update started encoding the Live Look links in my control panel, it exposed a problem with my server not handling those links properly. What I failed to mention was the error the link was showing in my browser which was "**The URI you submitted has disallowed characters.**"

Before the Live Look URL was encoded, I didn't have this issue, but now I do, or did.

I've had the particular site I'm speaking of on Dreamhost which seemed to only work properly when I'd set the "**uri\_protocol**" in my config file to "**QUERY\_STRING**". My setting of the uri\_protocol was related to my desire to get rid of the "index.php" in my URLs. I worked on the htaccess file so long ago, I don't recall the exact reasoning behind where I ended up.

Regardless of why I got to the point of use "QUERY\_STRING", I set it back to "AUTO", which is the default, and my LIVE LOOK links are working in the new encoded version. I suspect something has changed with my Dreamhost PHP set up in some automatic update that I didn't notice that allowed me to stop using "QUERY\_STRING."

So, in short, changing "**uri\_protocol**" in my config file from "**QUERY\_STRING**" to "**AUTO**" solved the problem with the encoded URL not working for me.

# Answer
> 1 votes
From the 2.5.3 changelog:

> Fixed a bug (#18071) where masked URLs in the control panel were not URL-encoded to protect characters like ampersands.

This should make the Live Look redirects more reliable. Are yours not loading correctly?

# Answer
> 0 votes
The first step to troubleshooting this would be to disable Extensions by adding this to your config.php file or by changing the config to "n" if it already exists in config.php.

```
$conf['allow_extensions'] = "n";

```

This will eliminate code in one of the extensions as part of the problem.

---

If this fixes your links, you'll know one of the Extensions is the problem. Unfortunately, you'll need to uninstall each Extension one at a time to figure out which one is the problem. Uninstalling the Extension will cause you to lose the settings for that Extensions so you'll need to re-setup settings when you install it again. This is a pain but there is no way around it. ***Make a backup of your database before starting this process so you can revert back if needed.***

Also, the issue might be caused by the Extension's priority for the extension hook it's using (1 =\> First, 10 =\> Last.). You can make changes to the priority by manually editing the "priority" column in the "exp\_extensions" table in the database. Looks at Extensions that will affect the Edit tab if that's where the problem URLs are visible.

---
Tags: control-panel, livelook
---


title: Stash Embeds - Trying to be DRY

text:
# Question
Title: Stash Embeds - Trying to be DRY
I'd like to know if/how Stash embeds could be used in a particular way. I'm trying to keep things DRY.
Generally my templates look something like this:

\_wrapper.html

```
<html>
<body>
    <header>...</header>
    {exp:stash:get name="content"}
    <footer>...</footer>
</body>
</html>

```

template.html

```
{!-- My 'view' --}
{exp:stash:set name="content"}
    <h1>{exp:stash:get name="title"}</h1>
    <p>{exp:stash:get name="description"}</p>
    <div class="sidebar">
        <p>Content that would be repeated across templates.</p>
    </div>
{/exp:stash:set}

{!-- My 'model' --}
{exp:channel:entries ...}
    {exp:stash:set}
        {stash:title}{title}{/stash:title}
        {stash:description}{description}{/stash:description}
    {/exp:stash:set}
{/exp:channel:entries}

```

The `<div class="sidebar">` might have something like a list of categories.
What I thought I could do was put that div in a Stash embed and then continue writing in the view/model format. It's not turning out that way.

In template.html I would replace the `<div class="sidebar">` with `{stash:embed:sidebar}`. Then sidebar.html would look like this:

```
{!-- Another 'view' --}
<div class="sidebar">
    <h2>Categories</h2>
    {exp:stash:get_list name="categories"}
        ...
    {/exp:stash:get_list}
    <h2>Something Else</h2>
    {exp:stash:get name="something_else"}
</div>

{!-- Another 'model' --}
{exp:channel:categories ...}
    {exp:stash:append_list name="categories"}
        ...
    {/exp:stash:append_list}
{/exp:channel:categories}

```

At the moment, `{stash:embed:sidebar}` does get embedded, but without the stuff inside `{exp:stash:get_list}` and `{exp:stash:get}`.
If this **can** be done, I'm sure a parse order issue. Perhaps a parameter on the embed tag would help. Although I don't know what.
If it can't be done, any suggestions for alternatives would be appreciated.

Thanks!

# Answer
> 34 votes
For me, one of the most compelling reasons to use a "template partials" approach in EE (or model-view-viewModel - MVVM - if you prefer) is being able to separate out the presentation of your data (e.g. the html markup) from the business and model logic that retrieves and formats the data (the template tags, conditionals, data formatting and so on). This decoupling of concerns has many advantages, such as the ability to easily change the presentation layer, to re-use layout templates, and to cache the captured data in a structured form and format it after retrieval from the cache.

While your question relates to a specific parse-order issue, I'm going to outline an approach, based on this idea of de-coupling the view and viewModel, which means you won't encounter parse order problems in the first place.

First, work out a common nonemaclature to describe the elements of a page into which you are going to inject content - regardless of where in your page layout(s) they might be used. To avoid collisions, don't use names that you are using for custom fields. E.g.:

```
{page_title}
{page_description}
{page_body}
{page_aside}
{page_nav_main}

```

Now work out which blocks of markup are likely to be shared across ALL layouts, and make them snippets.

{sn\_head} and {sn\_footer} are obvious examples, but as you put your layouts together you'll find many other blocks of markup that can and should be abstracted into snippets to keep things DRY.

**{sn\_head}**

```
<head><title>{stash:page_title}</title></head>

```

**{sn\_footer}**

```
<footer>footer</footer>

```

Then work out the main page layouts (the 'wrappers') for your site. For example, you might have a layout with a sidebar for internal pages, and one without for the landing page for each of your main sections. Make a /layouts/ folder in your Stash template directory and put these in:

**/layouts/landing.html**

```
<!DOCTYPE html>
<html>
    {sn_head}
    <body>
        <h1>{stash:page_title}</h1>
        <p class="description">{stash:page_description}</p>
        <div class="bodycopy">
            {stash:page_body}
        </div>
        {sn_footer}
    </body>
</html>

```

**/layouts/standard.html**

```
<!DOCTYPE html>
<html>
    {sn_head}
    <body>
        <h1>{stash:page_title}</h1>
        <p class="description">{stash:page_description}</p>
        <div class="bodycopy">
            {stash:page_body}
            <div class="sidebar">
                {stash:page_aside}
            </div>
        </div>
        {sn_footer}
    </body>
</html>

```

(Note that these may not look that different, but what if that changed in the future? Make a template for each layout that has a specific *purpose* in your site architecture)

You want to minimize or eliminate the passing of markup from your viewModel to your view, so if you have any sub-templates that provide formatting for a particular region of a layout, create a folder for them called 'partials'. E.g., 'sidebar\_list' would make a good partial:

**/partials/sidebar\_list.html**

```
<h2>{stash:aside_title}</h2>
<ul>
{exp:stash:get_list name="aside_list"}
    <li>{item_name}</li>
{/exp:stash:get_list}
</ul>

```

To make use of the layout templates your EE template (the 'ViewModel') needs to grab some data, include the relevant layout and inject sub-templates where needed:

**viewModel**

```
{!-- set the page layout --}
{stash:embed:layouts:standard}

{!-- inject the sidebar_list partial into the {stash:aside} region --}
{exp:stash:set_value name="page_aside" value="{exp:stash:embed:partials:sidebar_list}"}

{!-- main page variables --}
{exp:channel:entries limit="1" channel="blog" disable="member_data|pagination" require_entry="yes"}
    {sn_set_entry_fields}
{/exp:channel:entries}

{!-- sidebar variables  --}
{exp:stash:set name="aside_title"}Categories{/exp:stash:set}
{exp:stash:set_list name="aside_list" parse_tags="yes"}
    {exp:channel:categories}
        {stash:item_name}{category_name}{/stash:item_name}
    {/exp:channel:categories}
{/exp:stash:set_list}

```

If you have more than one viewModel, you're likely to be repeating the same *set* code. So encapsulate that as a snippet too:

**{sn\_set\_entry\_fields}**

```
{exp:stash:set}
    {stash:page_title}{title}{/stash:page_title}
    {stash:page_description}{cf_description}{/stash:page_description}
    {stash:page_body}{cf_body}{/stash:page_body}
{/exp:stash:set}

```

# Answer
> 13 votes
Here is the basic concept. I personally don't use the list tags to set a ton of individual variables. I find that it's too much and too tedious, and can perform an excess amount of queries if you have a lot of variables. I guess though it really goes down to how you prefer to organize your templates.

```
{exp:channel:entries}

    {stash:embed:your_context:your_template process="start"}

{/exp:channel:entries}

```

The above example would be embed into the channel entries BEFORE the entries loop is parsed. This for when you are constantly reusing the same markup in the loop, but the channel entries tag is different.

And then if want to embed a template after something has parsed, do this:

```
{stash:embed:sidebar process="end"}

```

It's really just manipulating the parsing order to get your tags to fire in the order you need.

Take a look at the homepage code from my site, objectivehtml.com. This is index.html of the default template group.

```
{exp:stash:set}

    {stash:page_title}Objective HTML - Top Notch ExpressionEngine Add-ons{/stash:page_title}
    {stash:page_class}home{/stash:page_class}
    {stash:section_title}Featured Product{/stash:section_title}

    {stash:page_sidebar}{stash:embed:objects:main_sidebar}{/stash:page_sidebar}

    {stash:page_content}

        {exp:channel:entries
            channel="articles"
            dynamic="no"
            disable="member_data|categories|category_fields|pagination"
            limit="1"
            status="featured"
        }

            {stash:embed:objects:article process="start"}

        {/exp:channel:entries}

    {/stash:page_content}

{/exp:stash:set}

{stash:embed:structure:header}

```

This is article.html, which is what I call a template object. I can insert an article on any page, just by including the article "object". And since I parse it first, it's included before any of the other tags have had a chance to parse.

```
<article class="article">

    {if segment_3 != url_title}

        <h3><a href="/articles/read/{url_title}">{title}</a></h3>

    {if:else}

        <h1>{title}</h1>

    {/if}

    {if !segment_3 && segment_2}

        {if article_excerpt}
            <p>{article_excerpt}</p>

        <p><a href="/articles/read/{url_title}" class="button small">Learn More <span class=    "icon-arrow-right"></span></a></p>

        {if:else}
            {article_content}
        {/if}

    {if:else}
        {article_content}
    {/if}

</article>

```

---
Tags: stash, parse-order, embeds, dry
---


title: files upload who owns them?

text:
# Question
Title: files upload who owns them?
I have a few sites that upload a lot of files. My problem is, when someone uses the file upload the files getting uploaded are not owned by anyone at the server level.

```
rw-r--r-- 1 nobody nobody

```

Because these files are not owned by anyone, they are not recorded as part of that user's storage space on their hosting account.

Does anyone have any ideas how to get the user to own these files when they are uploaded?

I should also note that the sites in question are EE1 sites using nGen File Field as the file upload. I am guessing it is a bug in nGen File Field?

# Answer
> 2 votes
This is a PHP/apache config issue rather than an EE issue per se. I've seen it before, mostly on cPanel boxes. What kind of environment are you running on the server/do you have full control of the server config?

By default on some older installs that use DSO (mod\_php) as the PHP handler, php runs as `nobody` (the apache user), resulting in `nobody` owning the files uploaded via PHP.

As it sounds to me as if php is running via mod\_php from the above, would it be an option for you to use FastCGI (aka: mod\_fastcgid) instead?

If you're running cPanel/WHM, changing the PHP handlers is very easy to do and only takes seconds. Log into WHM and navigate to: Main \>\> Service Configuration \> Configure PHP and SuExec

Then just select your PHP handler choice from the drop-down menu. Then hit “Save New Configuration”. If you don't see your desired choice in the drop-down menu, it may need to be compiled on the server first. Run an “Easy Apache” to compile it.

There's a good discussion of the different PHP handlers and their pros & cons here.

---
Tags: file-uploads
---


# Question
Title: In CartThrob, how can I determine whether a specific product is in cart already and therefore use it in a conditional?
I'm looking for a simple search of the cart contents. If a specific item I am looking for is already in cart (which I can simply define by the entry ID since the products are entries), I want to change the price applied in my add\_to\_cart form on the page to 0 (instead of the product's "usual" price). How can I do this? I don't think i want to do it with the cart\_items\_info tags from CartThrob - they have much more to them than I suspect I need.

So I'm aiming for something like this:

```
{if cart_contains_item_a OR cart_contains_item_b OR cart_contains_item_c}
{exp:cartthrob:add_to_cart_form return="" entry_id="{entry_id}" price="0.00"}
<input type="submit" class="button" value="Add" />
{/exp:cartthrob:add_to_cart_form}
{if:else}
{exp:cartthrob:add_to_cart_form return="" entry_id="{entry_id}" price="{cf_prod_price}"}
<input type="submit" class="button" value="Add" />
{/exp:cartthrob:add_to_cart_form}
{/if}

```

I'm just looking for guidance on the simplest way to determine what to include in the conditional.

# Answer
> 4 votes
You could use the `is_in_cart` tag for the conditional:

```
{if {exp:cartthrob:is_in_cart entry_id="{entry_id}"}}
   in cart
{if:else}
   not in cart
{/if}

```

# Answer
> 1 votes
This is what i managed to get to work. I wouldn't consider it the "right" answer without getting opinions from others, but it does work for me as intended:

```
{exp:cartthrob:cart_items_info entry_id="10|11|12|13" limit="1"}
{if no_results}
   INSERT MY ADD TO CART FORM WITH REGULAR PRICING
{/if}
   INSERT MY ADD TO CART BUTTON WITH DISCOUNTED PRICING
{/exp:cartthrob:cart_items_info}

```

In this particular case, because of how i add the items to cart, there will only ever be one of the entries indicated in the entry\_id parameter present anyway, so for me, this worked as a way to loop through the entries and determine if the specified entry id was present, and if so, apply special pricing rather than regular pricing to the add to cart button/form.

---
Tags: cartthrob, conditionals
---


title: Sticky Navigation Bar

text:
# Question
Title: Sticky Navigation Bar
I have set up my site in ExpressionEngine and I am trying to create a sticky navigation menu which indicates the section of site the user is on. Click Here for example when the user click on about the site scrolls down to about and the about stays in its hover state. I have incorporated the following but it doesn't seen to be working.

```
<ul class="nav-bar">
<li {if segment_1 == "home"} class="active"{/if}><a id="nav_1" href="#home">home</a></li>
<li {if segment_1 == "about"} class="active"{/if}><a id="nav_2" href="#about">about</a></li>
<li {if segment_1 == "roster"} class="active"{/if}><a id="nav_3" href="#roster">roster</a></li>
<li {if segment_1 == "clients"} class="active"{/if}><a id="nav_4" href="#client">clients</a></li>
<li {if segment_1 == "contact"} class="active"{/if}><a id="nav_5" href="#contact">contact</a></li>

```

# Answer
As coded, your active states will not work.

{if segment\_1 == "home"} class="active"{/if} will work only if the browser page is reloaded and segment\_1 becomes "home" in the address bar. Your hrefs aren't reloading the page, instead you are navigating with a scroll to "#home".

If you want active states, you'll need to use jQuery to set the active class on click.

```
$(".nav-bar a").click(function(){
      $(".nav-bar li").removeClass("active");
      $(this).parent().addClass("active");
});

```
> 16 votes

# Answer
You could have a look at this framework from "Zurb Foundation".

They have a plug-in (css & javascript) called "Magellan" that effectively "listens" to where a user is on the page and sets a class of **active** to the relevant menu item on a floating nav bar.

This means a user can either **click** on a menu item or **scroll** to the relevant part of the page and the nav item will be set to *active*.

It is not too hard to grab the bits of code and scripts you need out of the framework and add to your site.

http://foundation.zurb.com/docs/magellan.php
> 5 votes

# Answer
Best plugin I've used for this type of effect - no need to use EE conditionals.

http://pagescroller.com/
> 2 votes

---
Tags: templates, tags, navigation
---


# Question
Title: Possible idea why the smileys window for forum module shows homepage?
having an issue with the `{path:smileys}` tag in the submission form.html in the Forum module not showing the smileys in the popup window, but showing the entire homepage within the popup.

i've checked javascript, no issues. site is on a subdomain (dev.domain.com) and all other forum functions work.

here is the entire link:

```
<a href='javascript:void(0)' onclick="window.open('{path:smileys}', '_blank', 'width=700,height=180,scrollbars=yes,status=yes,screenx=40,screeny=120,resizable=yes');">{lang:smileys}</a>

```

want to replace that above code to a lightbox, but path isn't working correctly.

not sure what could be causing this issue, so any pointers or tips will help.

thanks

# Answer
> 2 votes
What ended up happening is there was a 'forum' template in the main template manager and is pulling in the forum content using the {exp:forum} tag.

Nothing wrong with this, except that the forum module templates were not adjusted for this. So in turn it was pulling in multiple sets of head and body tags. Basically doing an iframe setup without the iframe, that helps make sense of it.

It has led me to redo the forum module templates to accommodate for the forum template in the main template manager.

Hope this helps.

# Answer
> 1 votes
In my experience, any time the home page shows instead of anything, there can be two reasons why it isn't working:

1. The content you're trying to view is secure and EE redirects to the home page.
2. The path you're trying to access throws a 404 and no 404 has been assigned.

Check the path to your smileys in the general config and be sure that your .htaccess isn't rewriting it incorrectly.

# Answer
> -5 votes
Seems the issue ended up being poorly coded templates by previous dev.

---
Tags: forum
---


# Question
Title: Why are my P&T Assets folders taking 2 minutes to load?
I am using Assets to manage some of the images on my site. The CP loads as expected and nothing is too out of the ordinary. I have 196MB RAM set in PHP.ini and on a VPS.

When I click on an assets folder, the more images I have in there the longer it takes to load, which isnt so far-fetched, but it is taking around 2 minutes to load a folder with about 60 images in it. That same folder locally takes \< 5 seconds.

What can be causing this? Here is a screenshot of a XHR report.

# Answer
> 4 votes
It looks like the difficulty here was a very large number of folders and sub-folders. Condensing the folders down has sped up the load significantly and are working on improvements in that area for the future of Assets.

Thank you!

-Lisa Wess
Pixel & Tonic

---
Tags: assets, loading-time
---


# Question
Title: Are there any good add-ons for managing categories on the publish screen?
I have a channel that will require lots of editing (adding and selecting) of many categories and want to make this as simple a process as possible for the client. I also need to require that only one category can be selected at a time (unlike the multiple on the Categories tab).

Is there a decent fieldtype add-on that allows for managing categories, not just selecting them?

# Answer
None of the add-ons really did the trick so I ended up just dragging the categories field onto the Publish page from the Toolbar.
> 0 votes

# Answer
You can try my Category Field addon which should do exactly what your looking for:

> This field type allows you organize your category groups as you would any other custom field type anywhere on your publish entries form. Additionally a filtered input is provided for long category lists.

http://devot-ee.com/add-ons/category-field
> 4 votes

# Answer
This fieldtype is often overlooked, but I find for single-category entries, Lonely Cat by Wouter Vervloet to be amazingly simple and effective.

http://devot-ee.com/add-ons/lonely-cat

The advantage of Lonely Cat is in its ability to be instantly grasped by the user, and in the fact that it selects only one category at a time, though it can be configured to also select all parents of that category, as well.
> 3 votes

# Answer
I would suggest you use Playa for your categories. That will make it easy for your client to edit/add or delete categories.

1. It looks nice!
2. ease of use. (http://pixelandtonic.com/playa/docs/templates)
3. You can add a lot of extra fields to a single category.
4. Restrict that the client can select only one option (in this case a category).
> 3 votes

# Answer
The Category Field add-on mentioned by Nuno looks like it may cover it.

The Solspace Primary Category add-on provides another option for managing category selection, though likely not as in-depth as you are looking for.

http://devot-ee.com/add-ons/primary-category

Sometimes I also use Tags as an alternative for categories.

http://www.solspace.com/software/detail/tag/

http://www.devdemon.com/tagger/
> 1 votes

---
Tags: add-on, categories
---


title: Limit entry using status and categories

text:
# Question
Title: Limit entry using status and categories
I have a "featured item" part on my site that is controlled with a new status i created called "featured". I have 8 parent categories, and would like to have 8 different featured items, 1 unique for each category parent.

I am trying to make this dynamic so when I click on my category "central vacuum", then the item that is under the category central vacuums and has a status of featured to show.

I have come across a solution, which is to create 8 different statuses and then write 8 if statements, but I know theres another way around it I just can't seem to find one.

```
{exp:channel:entries channel="products" status="featured" limit="1" category_id="{segment_3}"}
     <img src="{feature_image}"/>
{/exp:channel:entries}

```

# Answer
If you're displaying your categories using standard category URLs (e.g., `/products/category/central-vacuum` or `/products/C12`), then you only have to add the `status` parameter to your Channel Entries tag (the category will be filtered dynamically based on the URL).

```
{exp:channel:entries channel="products" status="Featured"}
...
{/exp:channel:entries}

```

So in the example of the URL `/products/category/central-vacuum`, the code above would pull only products in the **Central Vacuum** category with **Featured** status.
> 4 votes

---
Tags: categories, segments, ifelse, status
---


# Question
Title: Minimee not working. How do I display template debugging?
I've installed Minimee. It doesn't seem to be combining CSS and JS files, despite them being wrapped in `{exp:minimee:css}` and `{exp:minimee:js}` respectively. Minimee is installed and "Combine Assets" are checked for CSS and JS (as well as "Minify").

When I view the rendered template, I still see the individual files itemized in the mark up. Basically, they weren't combined. They weren't minimized, either. NOTE: CSS and JS files are in templates.

It seems that when I check the minify HTML checkbox that it does affect the mark up a bit (though I thought it would minify it to the point that the HTML becomes a single line -- unless there are `<pre>` or `<code>` tags, I suppose).

Anyway, Minimee doesn't seem to be doing its thing. So, I am trying to debug it by turning on Template Debugging. I have set it in CPanel. However, I don't see anything on the rendered page that looks like template debugging. I am logged in as a Super Admin.

Any ideas what might be wrong with Minimee or Template Debugging?

**UPDATE 1:**

I created the cache folder in the wrong place (was confused since I am using MSM). It's been fixed now. Minimee is now creating the combined/minified CSS and JS and in the cache folder. It seems to also properly reference it from within the templates. However, it seems like what is being retrieved is the home page's HTML instead of the actual contents of the file in the cache folder. Still looking into this.

**UPDATE 2:**

Seems that there might be some sort of server issue. When I go to www.domain.com/cache/, I see the combined/minified JS and CSS files. However, when I click on them, I get a 404 error.

# Answer
> 1 votes
Is it possible your template is cached and so not rendering the correct version?

---

Template debugging will appear at the bottom of the page after enabling it in the control panel. If you don't see it, try inspecting the page to see if your reset CSS is somehow hiding it. Also, try setting up a blank test template, you should see the output on that page. **Check out this SE question**, perhaps you are hitting the same issue.

The debugging output will look like this:

---

Minimee, if I remember correctly, will create a new file name altogether. It will be obvious when it's working.

If you are using {path=} to create the JS or CSS urls, remove that and try just the path from root... eg: /global/js.

Try moving your JS/CSS to actual files to see if it combines them in that format.

If still not working, try the code in a new blank test template.

Another thing to try is to reupload all the addon files anew. Perhaps something was missed or corrupted?

# Answer
> 2 votes
I seem to remember somewhere that minimee wont work correctly if the css isn't valid. Can you check and see if the css validates? It might be that the minimee wont fire without it.

---
Tags: debugging
---


# Question
Title: Purge all unused files/assets from file manager?
Is there a way I can purge all unused files/assets via the file manager? I'd like to clean up some directories for a client? If not, is there a query I could use to find out which files are unused?

**UPDATE**

Adding a little more context, the files are used with a number of add-ons:

1. Native file fields
2. Matrix
3. Wygwam

# Answer
This will most likely involve building a custom PHP script to do this.

The first part of the script would do the audit to compile a list of all files currently in use in the various fields. You'd need to tell the script which columns hold the image data.

The second part of the script would run each file name against that list and delete the file from the filesystem if it's not present.

Once the script has run, you should purge your CE Image cache directory to remove all unused files. CE Image will regenerate newly re-sized files as needed.

**Back up the database and all files before starting this process.**

If you aren't able to write such a script yourself, there are many talented developers in the EE community who can. I have someone to suggest if needed.
> 1 votes

---
Tags: file-uploads, file-manager
---


title: White Home Page and CP

text:
# Question
Title: White Home Page and CP
Our site was working just fine yesterday. And when we go to it today it is blank on the homepage and CP.

I turned debugging on in index.php and admin.php and it returned:

```
Warning: require(/var/www/vhosts/domain.com.au/httpdocs/system-46cjg2378sW/codeigniter/system/core/Exceptions.php): failed to open stream:
Too many open files in /var/www/vhosts/domain.com.au/httpdocs/system-46cjg2378sW/codeigniter/system/core/Common.php on line 137 Fatal error: require():
Failed opening required '/var/www/vhosts/domain.com.au/httpdocs/system-46cjg2378sW/codeigniter/system/core/Exceptions.php' (include_path='.:') in /var/www/vhosts/domain.com.au/httpdocs/system-46cjg2378sW/codeigniter/system/core/Common.php on line 137

```

What on earth could have happened overnight? We haven't made any updates.

# Answer
As you all suspected it was an ISP issue. They took our server offline for a few hours last night and have resolved the issue. I have pushed them twice to provide a detailed answer about the issue in a hope to post it here in order to help others that might experience this problem.

This is the best I could get out of them:

> I've checked the details with our senior technicians, and as per their update, the issue has been resolved now. As updated in the network status page, we had experienced an intermittent connectivity to some websites on linux shared hosting. As it is a shared server, I'm sorry to say that, we are unable to provide you more details because of security reasons. I can confirm that the issue has now fully resolved.

Very non-specific, sorry.

Thank you to everyone that took the time to make suggestions about what we could do to try an solve it ourselves.
> 2 votes

# Answer
This isn't an answer to why it happened suddenly or what it causing it to open so many files, but if you have shell access on tour server, run ulimit -a and look for your open files limit. That is the number that you are running over that is causing your issue. If this number seems quite low, perhaps getting your host to raise it will be your solution.

I have seen similar errors reported with big sets of playa matrix fields. Do you have any monster channel field groups or anything like that that might cause this?
> 1 votes

# Answer
Check to see if your ISP made any updates. It's possible your version of PHP was changed overnight.
> 0 votes

---
Tags: ee2, control-panel
---


# Question
Title: Changing the distance metric in ObjectiveHTML's Google Maps
I'm using the Google Map Add-On from ObjectiveHTML. When entering a route using the field type in an EE channel entry the distance (as displayed in "Show Details") is always displayed in Kilometers. Does anyone know how this can be changed to display in miles?

# Answer
I uploaded a screenshot of my default setup. I simply create a Gmap field and create a route with an origin and destination. You can see my distance is in miles. I think Google is trying to automatically determine which metric to use.

I think what you propose is a good idea though. Being able to force that metric to be something would be nice. I will do some testing to figure out how to best get that data changed and I will report back here. But for now, I don't think it's a problem with the code, rather we just need a way to override the default.
> 2 votes

# Answer
I'm sure Justin (ObjectiveHTML) will correct me if I'm wrong, but I don't think there is a way to configure this as an option on the FT at current. It is possible to set a `metric` param on `{exp:gmap:search}` but that's no help here.

THough I don't have a copy of the addon's source, the The Google Directions API specifies a `units` parameter with values of either `imperial` or `metric`. If you're willing to dig in to the code you should be able to find where the request is generated and fairly easily add a `units=imperial` parameter to the request.
> 1 votes

---
Tags: add-on, google-maps-for-ee, fieldtype
---


# Question
Title: Is it possible to show the 'Login as member' link to non super admin groups?
Does anyone know if it's possible to show the 'Login as member' link, (available to super admins on Member Profile view, under 'Member Administration') to other member groups??

# Answer
Unfortunately this is not possible without hacking the EE core.

If you look at the `do_login_as_member()` function around line 590 of `system/expressionengine/controllers/cp/members.php` you will see:

```
    if ($this->session->userdata['group_id'] != 1)
    {
        show_error(lang('unauthorized_access'));
    }

```

ie, the access restriction of this function to superadmins is hardcoded into the core. You would need to either hack that file (and document it so that when you update EE you can reinstate it) or write an extension based on the code from that function.
> 3 votes

# Answer
This is not possible without hacking the core code. You could write an extension or something to do it most likely so you didn't have to hack the code, but bottom line is some code must be written.
> 1 votes

---
Tags: members, accounts
---


title: Cart Throb price calculations

text:
# Question
Title: Cart Throb price calculations
Has anyone ever had a similar issue in Cartthrob and have a possible solution

Product XYZ has 4 color options and 4 size options

color A in small is $46
color B in small is $45
color C in small is $40
color D in small is $40

color A in med is $66
color B in med is $65
color C in med is $57.50
color D in med is $57.50

color A in lrg is $86
color B in lrg is $85
color C in lrg is $75
color D in lrg is $75

color A in XL is $107
color B in XL is $105
color C in XL is $92.50
color D in XL is $92.50

How do I build a product that easliy allows the user to pick the size from a select list and the colour and CT calculate the price?

# Answer
Cartthrob supports price modifiers. The website is offline as I write this, but they may do what you want.

On the other hand, some of your numbers look like the prices are not standardized (ie. Medium is not always +$20 over Small, nor is Color A always $6 more than Color C). You may end up having to use the CartThrob hooks to modify the prices as items are added to the cart. With this option, the sky is the limit on your possibilities -- but it will take more thought and a little knowledge of PHP.
> 1 votes

# Answer
Here's a link to google's cache of the CT price modifiers docs for use while their site is still down.

CT permits you to use a matrix field for as your price modifier field, so with some extra columns and with the help of a little jQuery magic to make the UI nicer we can get to where you want to go.

Create your price modifiers matrix with additional columns for `colour` and `size` in addtion to the required `option` (url friendly value), an `option_name` (string) and a `price` value (ie a positive or negative amount to vary the base price by). Alternatively, avoid setting a base price and use the modifiers themselves to set the whole price of the product.

Additionally, structure your `option` value such that is is the colour and size values combined with a separator such as an underscore, eg `red_xl`, `green_xl`, etc.

Now in your template you can use the built-in CT `item_options` magic:

```
  <div class="default-options">
    {exp:cartthrob:item_options entry_id="{entry_id}" }
    {select}
        <option {selected} value="{option_value}">{option_name} {price}</option>
    {/select}
    {/exp:cartthrob:item_options}
  </div>

```

This is what non-js users will see, perfectly usable but not super friendly. Let's fix that with some jQuery. In your template we can write out a couple of JS objects from your `item_options` field:

```
  <script>
    var prodOpts = {
      sizes: [],
      colours:[]
    };
    {item_modifier_field}
      prodOpts.sizes.push({size});
      prodOpts.colours.push({colour});
    {/item_modifier_field}
  </script>

```

Then in an external script / on DOM ready, just hide the `.default-options` `<div>`, iterate over `prodOpts.sizes` and `prodOpts.colours` and build `<select>`s for each.

Inject these into the page and hook up some event handlers so that when both of your dynamically created selects have been set to non-default value, your hidden CT populated select is updated (you can get the value to select by concatenating the `size` and `colour` values together with your chosen separator).

I don't know what your JavaScript level is, and I'm not going to write the *whole* thing for you, but if you get stuck be sure to ask another question and I'll do my best to help out.
> 2 votes

# Answer
Cartthrob is about to release a product option configurator fieldtype which will be exactly what you need.

It allows you to create option groups (eg. color, size).
In each group you can options (eg. red, blue) and prices.

The fieldtype will automatically generate fields for every combination of option groups. (eg. large red, large blue, small red, small blue, etc).
It'll allow you to track inventory (optional) for each combination and calculate the prices automatically based on your options. You can also enter option names (perhaps an SKU) and labels (eg. Large Red) for the combinations.

Chris from CT tweeted a link to a short screencast about this recently.

If you can wait just a little longer, this'll be the ticket.
If not, you'll have to go with Tom's solution.
> 1 votes

---
Tags: cartthrob
---


# Question
Title: Static directory / subsite not managed by EE
I have a full EE2 site at domain.com. The problem I am running into is, I would like to have a separate non-EE managed site at something.domain.com and/or domain.com/something. It seems as though EE2 always takes over the URI, and my knowledge of .htaccess re-writing is limited. Is there a simple way to specify a directory that EE2 should not have control over?

Current .htaccess:

```
<IfModule mod_rewrite.c>
    RewriteEngine On

    AddType video/webm .webm

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

```

# Answer
htaccess can be directory specific so I'd be inclined to add a separate htaccess file for that directory and have

```
RewriteEngine off

```
> 1 votes

# Answer
Your current **.htaccess** file indicates that any files or directories actually found on the server will be served as-is. So if you throw some static files (or even another application) in a folder called **/foo**, it should load without that request being redirected through EE's controller.

These lines:

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

```

Are telling the server to only execute this line:

```
RewriteRule ^(.*)$ /~domain/index.php/$1 [L]

```

If the request is not an actual file or folder on the server.

For a subdomain, you'd want to look at your hosting control panel to set that up, and likely point it to a different webspace altogether.
> 1 votes

# Answer
If you are trying to use a subdomain for a different directory on the server to run a different set of content, then it seems to me you should be working on your virtual host settings and not .htaccess. I read your question to mean that you have an EE site at domain.com and you want a different site at subdomain.domain.com. That is something you would set up in virtual host settings. Requests to subdomain.domain.com should go into one virtual host and requests for domain.com should go in another. I would guess that your virtual host config currently looks something like this:

```
<VirtualHost xxx.xxx.xxx.xxx:80>
DocumentRoot /path/to/document/root
ServerName domain.com
ServerAlias *.domain.com

```

that ServerAlias is grabbing all traffic to all subdomains of domain.com, but most probably if you added another virtual host listening on 80 with ServerName subdomain.domain.com and a DocumentRoot pointing to wherever you want to put your files for this other site, your subdomain will now work for these other files.

If you want to have them in a subfolder, then the rewrite rule should not be touching them if the request if for a directory or filename that actually exists on the server. Your rewrite rule says only rewrite if this request is not an image file, is not a request for an actual existing filename, and is not a request for an actual existing directory. So if you have a folder in Document Root named /subfolder and in subfolder you have a file called index.html them a request to domain.com/subfolder/index.html really should load the file that is actually there.
> 0 votes

---
Tags: url, subdomain
---


# Question
Title: Moving member to a different group changes group permissions: Is this a bug?
I just created a new EE member group, then moved a member from group 2 into the new group, and suddenly the permissions for group 2 - the old group - have been changed. That group is no longer allowed to post into any channel.

Anyone ever seen this? Is this a bug?

# Answer
> 3 votes
This sounds like it could be related to this bug:

"Channel posting privileges being removed from member groups"

---
Tags: members, bug
---


# Question
Title: Pagination outside of channel entries tag?
I have a channel entries loop that I need to paginate but am having an issue with the location of the pagination code.

The channel entries loop surrounds a table structure but is inside the main table tags as to not repeat them.

The pagination code needs to be outside of the main table tags.

How can I achieve this?

# Answer
Sure - something like this (simplified obviously):

```
{exp:channel:entries paginate="bottom"}
    {if count == "1"}<table>{/if}
        <tr>
            <td>{content}</td>
        </tr>
    {if count == total_results}</table>{/if}
    {paginate}
        <p>Page {current_page} of {total_pages} pages {pagination_links}</p>
    {/paginate}
{/exo:channel:entries}

```

In this case, your pagination links should appear after your table closes.
> 9 votes

---
Tags: pagination
---


title: Multilingual tagging approach?

text:
# Question
Title: Multilingual tagging approach?
I'm looking for the best multilingual 'tag' approach.

Currently I'm exploring the Tagger addon from DevDemon.
I was thinking about splitting up the tags in different 'language'-groups,
but that doesn't seem like a good solution. Because, when adding/editing an entry... you would have to add each tag in all the different languages, wich will result in a huge (inconvenient) list.

Has anyone done this before & what was your approach?
Pros & cons?

# Answer
I've been longing for a multilingual tagging solution myself. You're right, even with groups, I'm not sure Tagger will quite get you there. Groupings are not visible in the entry screen, for example. Separate language groups would help you display language(group) specific tag clouds for example, but you'd have to add the tags then group them in the module's settings panel. Not ideal.

The one way I have done it for multilingual, though far from perfect, is to create a channel for tags, and use Playa to relate the tags to your entries, using categories to provide simple organization of the tags (starting with language, for example). Not as friendly as Tagger would be if it had a simple language "switch" available, but it does centralize the tags and allows you to use the Playa filter options to find the tags to assign. But this has its limitations too - the obvious one being that, unlike with tags, you cannot add new tags from within the entry screen - you'd have to add the tags first to the tags channel.
> 1 votes

# Answer
It's not ideal, but our approach has been to use primarily 'English' tags, unless a particular form language tag shows up a lot in search results. We use Tags by Solspace and it's great, but what we found is just as @Think Graphical mentioned, "the tags get cluttered very quickly, with all the multiple languages".

Our system, maybe different from others, so obviously, evaluate against what it is you're trying to accomplish. Our client basically produces multilingual publications on various issues concerning consumers— from credit to banking to identity theft, etc.

Frequently, the person searching for the publication in a particular language, doesn't actually speak that language or maybe can't read well in the language. For example, a social worker helping a first generation immigrant from Korea or the grandchild of a Hmong immigrant. The grandchild speaks English and Hmong, but may not read the language at all.

We found, when testing, that english language tags got more use than the foreign language tags, but search was a different matter. Since we were trying to limit the number of tags per entry (reduce clutter, improve/keep SEO ratings), removing tags duplicated in multiple languages was the first thing to go.

For us, search is fully multilingual compatible, and that's what we encourage for looking for multilingual words and phrases.
> 0 votes

---
Tags: add-on, multilingual
---


# Question
Title: How to pass form data to external php script
I need to pass a value from a form to an external php script via a url, but my code isn't working. When I submit my form, I'm expecting the url to look like this: example.com/script.php?zip=12345 but what I'm getting is this: example.com/script.php? with nothing after the ?. My form code is below. Am I doing something wrong, or do I need to change a setting somewhere?

```
        <form id="map" method="get" action="script.php">
            <input type="text" class="inline" id="zip" />
            <input type="submit" class="button" value="Go" />
        </form>

```

# Answer
You're missing the `name` attribute on the text field.

```
<input type="text" class="inline" id="zip" name="zip" />

```

You may just want to change `id` to `name` (that would depend on whether or not you're using the ID for any CSS/jQuery selectors).
> 2 votes

---
Tags: php, url, forms
---


# Question
Title: Conditional Global Variables OR simply not working
I've got

```
{if segment_3 == "desc" OR segment_4 == "desc"}

```

and EE is just ignoring it or not parsing it or something. I can try

```
{if segment_3 == "desc" || segment_4 == "desc"}

```

and that doesn't work either. However, if i have `{if segment_3 == "desc"}` on it's own, that works fine.

What's going on here huh?

More of the code around this, it's in a channel:entries tag and it's to define whether a orderby and sort paramater is applied:

```
{exp:channel:entries
channel="my_channel"
limit="15"
paginate="bottom"
{if segment_3 != "asc" OR segment_4 != "desc"} category={segment_3_category_id} {/if}
{if segment_3 == "desc" || segment_4 == "desc"} orderby="woa-price" sort="desc"{/if}
{/channel:entries}

```

# Answer
This is a parse order issue. The advanced conditional gets parsed after the channel entries tag. Try something like this:

```
{exp:channel:entries
channel="my_channel"
limit="15"
paginate="bottom"
category="{if segment_3 != "asc"}{segment_3_category_id}{/if}{if segment_4 != "desc"}{segment_3_category_id}{/if}"
orderby="{if segment_3 == "desc"}woa-price{/if}{if segment_4 == "desc"}woa-price{/if}"
sort="{if segment_3 == "desc"}desc{/if}{if segment_4 == "desc"}desc{/if}"
{/channel:entries}

```

Not sure if those conditions will match the URLs that you've got setup, but that is how you will have to do it. You need to use simple conditionals inside of the channel entries parameters.
> 5 votes

# Answer
You're running into a parse order issue here. This is because when you have multiple comparison operators in a conditional, that's an *advanced conditional*. Advanced conditionals are parsed *after* module tags (like `channel:entries`).

This solution might work for you though - use `preload_replace` variables:

```
{if segment_3 == 'desc'}
    {preload_replace:orderby="woa-price"}
    {preload_replace:sort="desc"}
{/if}
{if segment_4 == 'desc'}
    {preload_replace:orderby="woa-price"}
    {preload_replace:sort="desc"}
{/if}
{preload_replace:orderby="date"}
{preload_replace:sort="asc"}

```

Then you can use `orderby="{orderby}"` and `sort="{sort}` in your `channel:entries` tag.

This should work because these are simple conditionals, so they are parsed early, and because `preload_replace` variables saved based on their *first* parsed instance (so if your conditionals are met, the later declarations that are outside of the conditionals are ignored).
> 4 votes

# Answer
It may be treating the simple conditional and the complex conditional differently. Maybe try:

```
{if '{segment_3}' == "desc" OR '{segment_4}' == "desc"}

```

See if that then parses.
> 1 votes

---
Tags: conditionals
---


# Question
Title: How Can I Stop a Progress Bar at 100%, When Donations Exceed That Amount?
This maybe more of a PHP solve, but the website is in ExpressionEngine. I'm using a Matrix field, Store to process donations, and reverse relationships.

I basically set-up a progress bar using some PHP to showcase how much funds were raised for a youth. This works well, but assumed that people wouldn't continue to give if the record had hit 100% funded (really bad assumption, but it was only suppose to be a demonstration site, not a final product).

What's happening is that there are a couple of records that have been funded over 100%. I'm trying to figure out what would be a method to (1) trap the progress bar, so it never extends more than 100% width and (2) remove the give button if/when the raised amount equals 100% or more. I don't really care about someone giving $100 when the individual raising funds only needed $25 to be successful. I'm more concern to not not allow or at least make easy future donations after they've reached or exceeded 100% funding.

```
<div class="need-status">
    <hr class="none" />
    <div class="progress"><div class='value' style='width: <?=fixFloat($progress)?>%'><?=fixFloat($progress)?></div></div>
    <p class="stat money">$<?=fixFloat($total_given)?> of $<?=fixFloat($total_need)?> (<?=fixFloat(number_format($progress, 1, '.', ''))?>%)</p>
    <p><strong><?=fixFloat($total_donors)?></strong> supporters  <strong>Appeal Ends:</strong> {reverse_related_entries channel="appeals" status="open" orderby="date" sort="desc" limit="1"}{appeal_end_date format="%d %M %Y"}{/reverse_related_entries}</p>

    </div><!-- end Progress View -->

    <!-- start Needs View -->
    {reverse_related_entries channel="appeals" status="open" orderby="date" sort="desc" limit="1"}
    {embed="youth/_needs" entry_id="{entry_id}"}
    {/reverse_related_entries}
    <!-- end Needs View -->

```

I figured, it might be possible to encase the Store give button, in an id tag that shows/hide based on the outcome of progress details, but that's assuming I can set the progress bar to exactly 100% even if the amount is 130%, which I'm not certain how to do. The PHP variables are set in another portion of the page.

My PHP skills just aren't that great. The youth needs are stored in a Matrix field.

# Answer
Try this:

```
<?=fixFloat($progress) <= 100 ? fixFloat($progress) : 100?>

```

That code says: "if fixFloat($progress) is less or equal to 100, then output fixFloat($progress), otherwise output 100".

**Updated by Nonprofit Tech:** I used both @Justin's and @GDMac's response. For the progress bar, I added the `max-width: 100%;` to the inline style. But the solution for hiding the give button was in @Justin's code. I used like:

```
<div id="display_<?=fixFloat($progress) <= 100 ? fixFloat($progress) : 100?>">

```

Then added the following to my stylesheet

```
#display_100 {
    display: none;
}

```

This hides the give button when the give amount is 100% or over, but otherwise displays it for all the other randomly generated ids such as 46% or 89%. Thanks much!!
> 6 votes

---
Tags: expresso-store, php, matrix
---


# Question
Title: Upload File and write path to text-field in Frontend/User Edit Form
Is there a way to upload a file in a Frontend Edit Form (Solspaces «User») and write the new file-path into a member-custom-field (text-field).

The goal is to let users add/upload more than only one Membership-Photo to their profiles.

# Answer
I'm not sure how you could do exactly what you're asking, but have you considered using one of the member module add-ons like Profile:Edit or Zoo Visitor? They both allow you to tie a channel entry to a member, so you can have whatever custom fields you like. Profile:Edit has the added benefit of being developed on top of Safecracker, so it works exactly the same as a normal Safecracker form.
> 1 votes

---
Tags: members, file-uploads, solspace-user, saef
---


# Question
Title: What are some ways to offer stats to users?
I would like to offer stats such as "your article was read 50 times, your profile was viewed 25 times." I know Zoo Visitor does this, but are there alternatives?

# Answer
EE has **native entry tracking tags**.

> ExpressionEngine lets you track how many times a channel entry has been “viewed” on a particular page. Up to four different instances of the view counter can be used (each on a different page), enabling you to track different aspects of an entry independently. For example you can use view counter “one” to track views on your comments page and view counter “two” to track views on your permalink page.
>
> Note: The view tracking counter works in conjunction with the {exp:channel:entries} tag. Although you can show the number of views in any instance of your channel entries tag, the counter will only increment on pages that show a single-entry pages. Single entry pages are ones that show only a single entry, specified dynamically by the ID number or URL Title in the URL, such as comment or permalink pages.
>
> Also Note: If you have page caching enabled this feature will not work.

---

Additionally, Solspace has the **Tracker** module

> Tracker is a flexible application that allows you to track views for channel entries from site visitors. Instead of recording views per page, Tracker records views for each time a specific channel entry is loaded. Stats are available in intervals of days, weeks, months, and years. You can view a variety of overall and filtered down stats in the Tracker module control panel area, as well as entry-specific stats in the publish page using the Tracker field type.
>
> On the front end in your templates, you can display ranked lists of entries, stats for each entry, and charts/graphs for each entry. The tracking code that is placed in your templates is also available as a pixel image so you can track views on cached pages.
> 5 votes

---
Tags: zoo-visitor, users
---


# Question
Title: Why are my entry dates displaying incorrectly in Safari?
I'm not sure what could be causing this.

Dates are displaying incorrectly in Safari on my site. They are displaying as 1 day before the actual date that is set in the CP. I've never seen this and have absolutely no clue how to fix. All my searches have come up nothing.

For Ex: Entry Date in CP: 1/25/12

Chrome displays: 1/25/12

Safari displays: 1/24/12

# Answer
> 4 votes
Check your site's and user profile's localization settings. It's very likely that you're viewing the site in Safari while logged in as a user with a locale that differs from the locale configured for the site.

Documentation: Site Localization Settings, Enabling/disabling User-specific Localization

---
Tags: date, variable, bug
---


# Question
Title: Why am I getting different results from the template debugger locally to live
Why would the MB size on Begin Template Processing be so much different on a site hosted locally to that same site being put on a live server?

And does that have any relevance to page speed?

An example I have set up with just RAW data and minimal HTML shows these results:

## Locally

```
TEMPLATE DEBUGGING
(0.000006 / 1.90MB) Begin Template Processing
(0.000246 / 1.92MB) URI: news
(0.000260 / 1.92MB) Path.php Template:
…

```

## And then On a Dreamhost Server:

```
(0.000024 / 7.75MB) - Begin Template Processing -
(0.001825 / 7.81MB) URI: news
(0.001866 / 7.81MB) Path.php Template: /
(0.001904 / 7.81MB) Retrieving Template

```

# Answer
> 4 votes
I asked a similar question on Stack Overflow about **High Memory Usage in ExpressionEngine Templates**.

The smaller MB size on Begin Template Processing in attributed to APC bytecode caching being enabled on the server.

# Answer
> 5 votes
If you are using MAMP or similar locally/dev setup it likely has apc enabled for byte code caching, and the production server does not, as Mediagirl pointed out.

Likewise there could be other things related to that, php as mod\_php vs. not on the production server, different php versions and different php modules enabled, vs. not, and so on.

Also if you are like many, your local/development setup maybe a local SSD drive in a laptop vs. a network based storage system, or similar differences in local vs. production server setups. In the example above that last line you showed for the production server execution of 1.9 thousandths of a second, while that is slower than the 2 ten thousandth of a second for local/dev, I am not sure I would see that part is the defining portion of the "slowness" on the production server either.

# Answer
> 0 votes
In my experience, the performance is *always* better in production than dev. Seeing as you have the opposite, to me, it would look like your live server has some serious issues in terms of configuration. Serious, *serious*, issues. You might want to contact your host and ask them to look into things.

---
Tags: debugging
---


# Question
Title: Free ($0) products in expresso-store reports
We have a (rare) situation where there are free items being 'sold' alongside paid items in an expresso-store. But we've noticed that these items don't appear in the **Reports** \> **Orders** Report area of the module.

Any idea if this is possible, or suggestions on where to look to allow this?

# Answer
> 3 votes
That sounds like a bug, there are no settings which would affect the display of free items.

Can you please email support@exp-resso.com and we will follow up for you.

---
Tags: add-on, expresso-store, ecommerce
---


# Question
Title: CartThrob and Sage: Changing Order ID (T_ordernum)
I am using CarthThrob and Sage Payments NA (Bank Card HTTPS) to process transactions. Using the standard Sage US payment gateway it does work, but I need to edit the Order ID (T\_ordernum in the Sage docs) to include some items specific information. Right now it is the entry\_ID plus a timestamp: 123\_1234567890 which is meaningless in our system.

I'd like it to use some custom field data: account number and last name so orders appear in Sage as: 123\_Lastname (maybe adding the timestamp for randomness).

I am capturing these as item\_options in the add to cart form:

```
{exp:cartthrob:add_to_cart_form
    return="cart/review"
    entry_id="{entry_id}"
    allow_user_price="yes"
    item_options:account="{ma-number}"
    item_options:last_name="{ma-lastname}"
    }

```

However the payment gateway creates the Order Number from the entry\_id and Unix time:

```
'T_ordernum'=> $this->order('entry_id')."_" .time(),

```

I'd like to have it grab those item variables. I've added this (found in another payment gateway):

```
$reference = '';
    if (!empty($item['item_options']['account']))
    {
        $reference .=$item['item_options']['account'] ."-";
    }
    if (!empty($item['item_options']['last_name']))
    {
        $reference .=$item['item_options']['last_name'] ."-";
    }

```

The issue we (the php guy here...I'm more design/front end) have is getting $item info. We don't see where that is coming from.

I realize this is a longshot (did contact CartThrob but they are relaunching their site and been very busy the last few weeks). If it is an easy fix and you can post it here, great. If you want to do this for pay, I'm open to that as well (if that is not allowed here let me know and I'll remove this question).

# Answer
You can access the order items as an array in the payment gateway:

```
$items = $this->order('items');

foreach ($items as $item) {
    echo $item['item_options']['foo'];
}

```
> 3 votes

---
Tags: cartthrob
---


title: Custom CP for Members

text:
# Question
Title: Custom CP for Members
I'm trying to develop a membership website. I'm using SafeCracker Registration so I can leverage Channels for member data. Once members are registered and verified, I want them to be able to do the following:

* Log in from a customized login page
* Have their own control panel where they can edit their profiles (I'll build the SafeCracker forms); I don't want them seeing the EE CP.
* Use EE's build in emailing system so members can email each other (I don't want to build this myself)

So, my questions are:

1. What is the proper way to customize the login page? The changes I want to implement include mark up changes, content changes, and other design changes.
2. How do I tell EE that when a member of a particular member group logs in that they should be redirected to the customize CP that I plan to build?
3. How do I let my member use EE's email system so that members can email each other? Ideally, I'd like to redo the markup for this (to make it responsive using Twitter Bootstrap), but I'm happy to just use whatever EE has initially as I am concerned it may be too much effort trying to make changes to it.

# Answer
> 5 votes
**What is the proper way to customize the login page?.**

Just pop the native **Login Form Tag** into your template. You'll want to use the **Login Redirect extension** to get around the annoying default "you are logged in" message.

---

**How do I tell EE that when a member of a particular member group logs in that they should be redirected to the customize CP that I plan to build?**

On the Login Form Tag set the `return=""` parameter to a template which will handle the redirecting... ex: `return="members/redirect"`.

Inside that template, setup conditionals to handle the redirects to the unique templates. These conditionals will match the member group of the logged in user.

```
{if "logged_in_group_id" == "1"}{redirect ="members/group1"}{/if}

```

---

**How do I let my member use EE's email system so that members can email each other? Ideally, I'd like to redo the markup for this (to make it responsive using Twitter Bootstrap), but I'm happy to just use whatever EE has initially as I am concerned it may be too much effort trying to make changes to it.**

These are two are worth evaluating for private messaging. I haven't used either of them.

**Messaging**
"Messaging is the module for ExpressionEngine 2 that brings all power of Private Messages, Bulletins (public messages) and Buddies/Blocked lists to frontent templates - even with AJAX support!"

**Friends**
"Allows your users to create and manage lists of friends, along with complete private messaging, status updates, comment walls, referral tracking, and virtual groups."

# Answer
> 2 votes
3) Solspace Friends Module offers access to the messaging system in templates http://www.solspace.com/docs/friends

---
Tags: control-panel, members, member-details
---


title: Disable "Invalid GET Data" Error

text:
# Question
Title: Disable "Invalid GET Data" Error
I have a site that's being ported to ExpressionEngine as a temporary stopgap while a longer term strategy is worked out. The issue is that there are URLs in Google (and the wild) that have "bad" query strings from the previous (Java) build so when a user visits a URL from the old site they get a generic "Invalid GET Data" error.

Is there a way to allow for those characters in an ExpressionEngine URL?

# Answer
You can enable specific characters by going to your EE config/config.php file.

Find the **permitted\_uri\_chars** config variable.

Here is the default:

```
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\\-';

```

Additionally, you may want to take a look at the **enable\_query\_strings** config too. You want to change it to:

```
$config['enable_query_strings'] = TRUE;

```
> 11 votes

# Answer
In addition to what Justin recommends, open up `system/expressionengine/core/EE_Input.php`, and find the `preg_match()` call at the end of the `filter_get_data()` function. Any semi-colons or question marks (encoded) in your GET variables will cause you to be filtered.

Think about security before you edit this function, but I have found it to be necessary at times also.
> 3 votes

---
Tags: url, get
---


# Question
Title: authentication on EE website from another device
Can i login to EE website from another device, ie iOS device. Basically i have a website with users, i need to login to it from a mobile phone application. Is it possible? I know that EE server generates XID entry for protection Is there any way around it?

We are developing an iOS application and trying to register member to the Member Group by providing fields(screen name, password, confirm password, email), we are planning to post these variables to php script and insert it into the ee database table(s). What are these tables ? Is there any place we can se examples of php script? what else do we need to consider?

# Answer
I think this question is a little vague, you need to clarify what exactly you are trying to do. I'd also question whether EE makes a good backend for any sort of mobile app, you are probably better off writing your own backend app directly in PHP, or looking at something like Parse, however, I digress.

The principles are simple enough. This has already been done by Mountee, for example. To log in to EE from a native app, there are three steps:

1. Generate an XID (just request the login page, and parse the response to get an XID value). If you create your own PHP login script you can avoid this requirement.
2. Submit the login form
3. Record the session cookie in your app and use it for future requests

As far as actually creating new members in the database - it is best to use the built in EE functions as much as possible for this. The EE member API is a bit of a minefield, and wasn't written with re-use in mind. However, with some tricks it is possible to call the functions and avoid any issues which may arise from changes to the database schema in future.

Your best starting point is probably to take a look at the open source Freemember plugin, which allows you to create front-end member registration & login forms. You could also use its library which abstracts the process of registering new members.
> 3 votes

# Answer
A more programatic approach to this could involve creating an ACTion URL. There is not much documentation about them except to read through the EE codebase, but these URLs could remove the need to deal with XIDs.

From http://ellislab.com/expressionengine/user-guide/development/module\_tutorial.html:

```
$data = array(
    'class'     => 'Download' ,
    'method'    => 'force_download'
);
$this->EE->db->insert('actions', $data);

```

Note that the method has to be inside of a class in either your mod.extension.php or mcp.extension.php files. You access them like this:

http://www.example.com/?ACT=21

Where the number after ACT is the row ID from the "exp\_actions" table that references your class and function.

With this you will have a partially-loaded EE environment so that you can register users (or check login credentials) through the appropriate methods. **I do recommend using SSL and also rate-limiting requests through this interface.**
> 2 votes

---
Tags: forms, login, users, xid, authenticate
---


# Question
Title: How do I display categories assigned to entry within Channel entries tag
In my code below I'm trying to list the category\_url\_titles within data-type. This is returning all the categories for that channel, but I only want to show the categories assigned to that entry. I thought maybe there would be an entry\_id="{entry\_id}" thing for the channel categories tag, but there isn't. Any ideas?

```
    {exp:channel:entries channel="locations" dynamic="no"}
    <a href="{title_permalink=locations/details/}" data-type="{exp:channel:categories style="linear" }{category_url_title} {/exp:channel:categories}"></a>
    {/exp:channel:entries}

```

# Answer
> 6 votes
Within your `channel:entries` loop, use the categories loop:

```
data-type="{categories backspace="1"}{category_url_title} {/categories}"

```

---
Tags: categories
---


title: MSM Bootstrapping

text:
# Question
Title: MSM Bootstrapping
I've just added a secondary site to my Git-bootstrapped EE-site. I've added new upload destinations and I've added them to my file-uploads array in my `config.php`. My file-uploads array looks like this now (just a stub, obviously there are more like this):

```
10 => array(
    'name'        => "Blog",                          // Display name in control panel
    'server_path' => $base_path . '/user/blog/', // Server path to upload directory
    'url'         => $base_url . '/user/blog/'      // URL of upload directory
),

```

With `$base_path` and `$base_url` defined as follows:

```
$base_url                       = $protocol . $_SERVER['HTTP_HOST'];
$base_path                      = $_SERVER['DOCUMENT_ROOT'];

```

Now this poses a problem: when I administer the secondary site through the admin.php of the primary-site, obviously `$base_path` and `$base_url` are going to resolve to that site's domain and document-root. How do I handle this properly? Reason this is causing such a headache is that the secondary site has some issues that cause it's admin.php to not render theme-url properly (forum-thread here: http://expressionengine.com/forums/viewthread/229911/).

Any help would be greatly appreciated!

# Answer
> 5 votes
So I'm inferring from the forum post you linked that you're bootstrapping your config with something like NSM bootstrap or similar in order to reduce the pain of moving EE between multiple environments (local/staging/production etc.). That's a great idea, and how I roll with EE myself (though take a look at FocusLabs Master Config for another, more in depth approach to this.

However in this particular case I don't think there's a way to avoid hard coding the URL and server paths for each site, given that $\_SERVER is necessarily unaware of any sites other than the current execution context, and MSM doesn't even require you to define your domain anywhere, (leaving aside that we need to do all this before EE has loaded anyway).

That said, we can at least make sure you only have to store that information in as few locations as possible, and still make it easy for multiple dev's to have different absolute paths to their local installs etc, by loading per environment config files, based on an environment constant:

```
define('EE_SERVER_NAME', $_SERVER['SERVER_NAME']);
switch (EE_SERVER_NAME) {
    case 'site1.local';
    case 'site2.local';
      define('EE_ENV', 'local');
      break;
    case 'staging.site1.com';
    case 'staging.site2.com';
      define('EE_ENV', 'staging');
      break;
    case 'site1.com';
    case 'site2.com';
    default;
      define('EE_ENV', 'production');
      break;
  }
}
/* load environment specific config file
 note you could do this inside the switch above, but setting environment
 constants is super useful and gives more flexibility.*/

require_once('./config.'. EE_ENV. '.php');

```

in config.production.php

```
define('EE_SITE1_BASE_PATH', '/path/to/site1');
define('EE_SITE1_BASE_URL', 'site1.com');
define('EE_SITE2_BASE_PATH', '/path/to/site2');
define('EE_SITE2_BASE_URL', 'site2.com');

```

in config.local.php, which is ignored from version control: *(include a config.local.example.php to allow new devs to get up and running)*

```
define('EE_SITE1_BASE_PATH', '/different/path/to/site1');
define('EE_SITE1_BASE_URL', 'site1.local');
define('EE_SITE2_BASE_PATH', '/different/path/to/site2');
define('EE_SITE2_BASE_URL', 'site2.local');

```

upload directories:

```
//this dir belongs to site 1
9 => array(
    'name'        => "Images",                          // Display name in control panel
    'server_path' => EE_SITE1_BASE_PATH . '/user/images/', // Server path to upload directory
    'url'         => EE_SITE1_BASE_URL . '/user/images/'      // URL of upload directory
),
//this dir belongs to site 2
10 => array(
    'name'        => "Blog",                          // Display name in control panel
    'server_path' => EE_SITE2_BASE_PATH . '/user/blog/', // Server path to upload directory
    'url'         => EE_SITE2_BASE_URL . '/user/blog/'      // URL of upload directory
),

```

As an aside, you should probably use constants like BASE\_PATH instead of $base\_url, to prevent them being accidentally reassigned, and to make your code/intent clearer to other developers who might come after you.

*I've also assumed that you're not trying to declare two upload destinations (one for each site) as a single upload directory definition in config.php. I'm pretty certain that ain't gonna work...*

# Answer
> 1 votes
I know this has already been answered by Tom. But if you are using the Focus Lab Master Config, you could modify the /config/config.env.php similar to this:

```
if ( ! defined('ENV'))
{
    switch (str_replace('www.', '', $_SERVER['HTTP_HOST']))
    {
        case 'mydomain1.local' :
            define('ENV', 'local');
            define('ENV_FULL', 'Local');
            define('ENV_DEBUG', TRUE);
            define('ENV_BASE_PATH', '/Users/yourname/Sites/mydomain1.local');
            define('ENV_BASE_URL', 'mydomain1.local');
        break;

        case 'mydomain1.tld' :
            define('ENV', 'prod');
            define('ENV_FULL', 'Production');
            define('ENV_DEBUG', FALSE);
            define('ENV_BASE_PATH', '/var/www/vhosts/mydomain1.tld');
            define('ENV_BASE_URL', 'mydomain1.tld');
        break;

        case 'staging.mydomain1.tld' :
            define('ENV', 'staging');
            define('ENV_FULL', 'Staging');
            define('ENV_DEBUG', FALSE);
            define('ENV_BASE_PATH', '/var/www/vhosts/staging.mydomain1.tld');
            define('ENV_BASE_URL', 'staging.mydomain1.tld');
        break;

        case 'mydomain2.local' :
            define('ENV', 'local');
            define('ENV_FULL', 'Local');
            define('ENV_DEBUG', TRUE);
            define('ENV_BASE_PATH', '/Users/yourname/Sites/mydomain2.local');
            define('ENV_BASE_URL', 'mydomain2.local');
        break;

        case 'mydomain2.tld' :
            define('ENV', 'prod');
            define('ENV_FULL', 'Production');
            define('ENV_DEBUG', FALSE);
            define('ENV_BASE_PATH', '/var/www/vhosts/mydomain2.tld');
            define('ENV_BASE_URL', 'mydomain2.tld');
        break;

        case 'staging.mydomain2.tld' :
            define('ENV', 'staging');
            define('ENV_FULL', 'Staging');
            define('ENV_DEBUG', FALSE);
            define('ENV_BASE_PATH', '/var/www/vhosts/staging.mydomain2.tld');
            define('ENV_BASE_URL', 'staging.mydomain2.tld');
        break;

        default :
            define('ENV', 'local');
            define('ENV_FULL', 'Local');
            define('ENV_DEBUG', TRUE);
        break;
    }
}

```

In config.master.php you could change this;

```
$images_path = $base_path . '/' . $images_folder;

```

to this;

```
$images_path = ENV_BASE_PATH . '/' . $images_folder;

```

I think this would save you from needing to create EE\_SITEX\_BASE\_PATH etc.

---
Tags: multi-site-manager, bootstrap, git, file-uploads
---


# Question
Title: How can you remove the list html from GWcode categories add-on?
I'm using GWCode Categories add-on (http://gwcode.com/add-ons/gwcode-categories) to output a custom field from a category.

However, i cannot see anyway to get it not to output the list html i.e

* custom field content

\- i just want it to output the custom field content and nothing else.

Does anyone know how to do this?

Thanks

# Answer
> 1 votes
Whoops, i had a spelling error in there, the answer is:

```
style="linear"

```

Sorry!

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


# Question
Title: Search results pagination and ordered list numbering
I have a search form with pagination that has a limit of 10 results per page. The problem is that the numbering of the ordered list is not continuous and starts over on each page. For example, if the search produced 15 results, page 1 would show results 1-10 and page 2 would show 1-5 rather than 11-15. Is there another way to format the results so that the numbering is continuous?

```
<ol>
    {exp:search:search_results paginate="both"}
        <li>
          <h4><a href="{if page_url != ''}{page_url}{if:else}{auto_path}{/if}">{title}</a></h4>
          {excerpt}
          <p><a href="{page_url}">{page_url}</a></p>
        </li>
    {/exp:search:search_results}
</ol>

{if paginate}
    <div class='paginate'>
       <span class='pagecount'>{page_count}</span>  {paginate}
    </div>
{/if}

```

# Answer
This is a reported bug that has been fixed. The patch can be found here: https://support.ellislab.com/bugs/detail/18337
> 0 votes

# Answer
Do away with the `<ol>` and use the variable `{absolute_count}` instead.
> 8 votes

# Answer
Low is totally correct, but I thought it might be worth adding some info about why this is necessary and how you might implement his solution.

The reason the counters on your `<ol>` appear 'off' is that they are automatically generated from the HTML document, which has no awareness of your pagination, so as each page is a new ordered list the first item in the list is numbered '1', no matter what page you are on.

My approach to implementing counters in the way you want is to use `{absolute_count}` combined with data attributes and CSS pseudo-elements, like so...

HTML;

```
<li data-count='{absolute_count}'>{title}</li>

```

CSS:

```
li {
  list-style: none;
}
li:before {
  content: attr(data-count);
}

```

This way you can still use an `<ol>` for semantics but get the counters the way you want them.
> 4 votes

---
Tags: search, pagination
---