title: Charge – Change currency

text:
# Question
Title: Charge – Change currency
I'm trying out Charge for a membership website, and need to change the currency to Singapore Dollar SGD. It is not listed as default currency in settings.

I've tried using {exp:charge:form plan\_currency="sgd"} but it throws a "Currency - Not a valid currency" error.

I can't seem to find any other info in the documentation or here.

# Answer
I got it to work by manually adding the currency in 3 separate files:

```
charge > mcp.charge.php
charge > models > charge_stripe_model.php
charge > language > english > lang.charge.php

```
> 0 votes

---
Tags: stripe, charge
---


title: Stash segment for use on other page

text:
# Question
Title: Stash segment for use on other page
I want to save segment\_3 for use on another page for each user, I think the following should work:

```
{exp:stash:set name="selected_category_url" scope="user" save="yes"}
   {exp:streeng slug="yes" lower="yes"}
     {segment_3_category_name}
   {/exp:streeng}x
{/exp:stash:set}

```

On next page:

```
{exp:stash:get name="selected_category_url" scope="user" save="yes"}

```

But this isn't working, I've tried various mixes of 'scope' 'user' in both tags, but no luck, what am I doing wrong?

# Answer
Make sure the tag you are capturing is actually parsed before you try to save the variable, otherwise you will capture the literal tag pair rather than its output:

```
{exp:stash:set name="selected_category_url" scope="user" save="yes" parse="yes"}
   {exp:streeng slug="yes" lower="yes"}
     {segment_3_category_name}
   {/exp:streeng}
{/exp:stash:set}

```

Get it like this:

```
{exp:stash:get name="selected_category_url" scope="user"}

```

Make sure you have `$config['stash_cookie_enabled'] = TRUE` in your config, otherwise the `user` scope will be unavailable.
> 1 votes

---
Tags: stash
---


title: Channel entries without URL field

text:
# Question
Title: Channel entries without URL field
Is it possible to have a channel where you do not have to define a URL name for every entry. I want to have a channel for events which are only shown in a list (no extra page for each event) so it would be quite annoying to always come up with a unique id for the URL field.

Thanks in advance!

# Answer
> 1 votes
Automatic creation of unique URL titles was a built-in feature of EE in v2. Apparently it was removed with v3. You can see some discussion of the issue on this bug report https://expressionengine.com/support/bugs/21902/adding-a-new-entry-with-the-same-title-as-an-existing-one-does-not-auto-gen

Looks like there are **no plans to bring this functionality back** in later versions of EE. I'm surprised. It seemed like a smart feature and good for users.

That discussion does reference a **plugin** called **Smart URL Title** which can be used as a patch for this. https://github.com/willowlight/Willow-Smart-URL-Title

> This addon will check for an existing URL Title in the same channel and automatically append it to avoid errors when saving the entry.
>
> Example, if an existing URL title willow-smart-url-title exists, the addon will change it to willow-smart-url-title-2. It will also increment the number (up to 10) if future entries share the same URL title.
>
> Additionally a message will be displayed under the URL Title field to let the editor know that a duplicate URL was found, and the URL Title was modified to avoid errors.

# Answer
> 0 votes
When you create a title for a new entry, the URL title is auto-generated as you can plainly see. The URL title will always be required for every entry.

Just because each entry needs to have a unique URL title doesn't mean it needs to be used in anyway; it's just a unique identifier. Unfortunately it has to be unique and you won't be able to save a new entry until it is.

The only solution I could think of for this is creating a helper add-on to warn you before you try to save your entry that the URL title isn't unique, or automatically add an index counter to the end (so if you enter a title of "Test Entry", a URL title of "test-entry" is generated, but the add-on finds that title already exists, so it tries "test-entry-1", and if that exists, tries "test-entry-2", etc..).

It might be a fun side project to build, but I'm not sure it's worth it instead of just manually adding a "-1" (or "-2", "-3", etc..) to your URL titles if the title is already taken.

---
Tags: channel-entries, url, ee5
---


# Question
Title: Adding freeform PRO to expression engine
I have had a website built for me using EE and am now needing to add a plugin. I free form lite installed and put in the license key for freeform PRO but cannot access CRM area. (keeps saying to upgrade).

Do I upload the plugin add-on to the general website files for PRO?

I see only a limited view in the back office (I guess the way the CMS was built). and nowhere specific to upload the PRO plugin. Any help would be great.

# Answer
I think you have to download from Solspace and then upload on your server in your addons folder. I guess there's more infos on Solspace doc/website how to upgrade.

And it looks like you not logged as super admin in the CP.. maybe you won't able to install/update to pro
> 0 votes

# Answer
Once you purchase an upgrade from Lite to Pro, you receive access to a new set of Freeform files that include both the Lite and Pro features in the download package. You'll need to download the Freeform Pro package from your Solspace account, then replace the current files with the new files on your server. The license key in itself does not enable/activate any Pro features. :)
> 0 votes

---
Tags: solspace-freeform
---


title: freeform add datepicker to text field

text:
# Question
Title: freeform add datepicker to text field
I cannot get my datepicker to work in the freeform demo templates. I have included the css, jquery and jquery UI. THe datepicker works on a test page when not in a freeform, but it will not ork once I add it to a freeform

`href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css
https://code.jquery.com/jquery-1.12.4.js
https://code.jquery.com/ui/1.12.1/jquery-ui.js
script type="text/javascript">
 $('#form-input-date').datepicker();
/script
input name="date" type="text" id="form-input-date" class="form-control " maxlength="" placeholder=""`

# Answer
> 1 votes
I had to remove the jquery in the inc\_footer

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


# Question
Title: Simple Registration very slow response times
Recently rolled out the latest version of Expression Engine (5.1.2) and upgraded our PHP version to 7.2 and noticed a massive drop in the response times from our signup forms the using Simple Registration addon.

We used to receive a response in under a second, now it takes 10+ seconds to register a user or return an error message.

I'm wondering if this is just a compatibility issue with the latest version of EE (or php) or if it's something else?

Any thoughts?

EDIT: Worth mentioning that the members table is very large, but I've tested other plugins and they don't have the same problem. Would like to continue using Simple Registration if there is a solution to this problem, as it has functionality that I have been unable to find in other member addons.

# Answer
This appears to have been a problem with my server config running the queries slowly, not with Expression Engine or the Simple Registration plugin. It's odd that this problem occurred when upgrading to EE 5.1.2, but I have recently moved to a new hosting provider and speeds have increased dramatically.
> 1 votes

---
Tags: registration, ee5, simple-registration
---


title: CE Image + AWS usage

text:
# Question
Title: CE Image + AWS usage
I'm probably being a bit dim, but how do you use CE Image with AWS?

I've added the CE Image and the CE Image - AWS plugins, and added the AWS config stuff, what next, I expected to see new field types or something?

How do fields know they should upload to AWS?

# Answer
Ce img is not a fieldtype where you can expect any fields. It is image cropping and scaling plugin. AWS is a different plugin which gives you ability to upload/fetch images to/from bucket.

Implementation is pretty simple. Suppose you have a file field (image) in entry. At frontend template you will write something like this:

```
<img src="{image_field}" />

```

This will give you original Image. Now with CE Image, You will write something like this:

```
{exp:ce_img:single src="{image_field}" width='100' height='100' crop="yes" quality="75" cache="no" overwrite_cache="yes" allow_scale_larger="yes" attributes='class="ce_image"'}

```

I have added most common parameters but required paramter is only `src=''`

To implement AWS, You just have to add one more parameter: `bucket="myBucketName"` and image will start uploading and fetching bucket URLs.

I suggest you to go through documentation here: https://docs.causingeffect.com/expressionengine/ce-image/user-guide/variables.html#aws-url
> 2 votes

---
Tags: ce-image, aws
---


# Question
Title: How to - configure EE to play nice with https...?
Does anyone know about any resources that explain how to get EE2 to play nicely with SSL certificates please?

Thanks!

# Answer
My general steps are:

1. Set up General Configuration \> URL to the root directory of your site to use https.
2. Set up File Upload Preferences \> \> URL of Upload Directory to use https. This makes sure your images/documents are properly linked.

To catch any other http references:

1. View source of your web page and search "http:".
2. Search for "http:" in your file tree (grep -r 'http:' /path/to/ee/root).
3. I've never had to go this far, but Developer Tools \> Network might shed light if some something embedded deeper is making http calls.
> 1 votes

# Answer
Sussed it out - a couple of EE Addons had been set with hard-wired base URL entries that I had missed - so when I set it to HTTPS operation, they continued to serve items using the hardwired (non HTTPS) URLs. One of these was Minimee and so none of the style sheets or js loaded due to insecure content.
> 0 votes

---
Tags: ee2, ssl
---


# Question
Title: Cartthrob Error after Update 4.2 and EE 5
Updated EE 3 to EE 5 and Cartthrob to 4.2.

Now we get this error message

```
    Warning
A non-numeric value encountered
user/addons/cartthrob/cartthrob/core/Cartthrob_product.php, line 151

Severity: E_WARNING`

```

Any ideas where to fix this?

EDIT:

After the fix from Harsh Barach we have this error message left

```
Warning
A non-numeric value encountered
user/addons/cartthrob/libraries/Cartthrob_variables.php, line 625

Severity: E_WARNING

```

Appreciate some help here.

# Answer
You can try by adding type-casting to it. Try like below manner in the file from this path `system/user/addons/cartthrob/cartthrob/core/Cartthrob_product.php, line 151`.

Change `$price += $row['price'];` to `$price += (int)$row['price'];` in line 151. *I hope this will works for you.*

You need to add type-casting here like this way `$taxed_price = (int)$price * (1 + ee()->api_cartthrob_tax_plugins->tax_rate());` in line 625. *I hope this will also works for you*
> 0 votes

---
Tags: cartthrob
---


# Question
Title: call template partial using a channel field?
I am not sure if what I am trying to do is possible. I am definitely not succeeding.

What I need is to have a channel field that calls a template partial, preferably a text field where I can type in the name of the partial or a drop down menu, where the partial name can be selected.

The plan being that if in the entry form, the partial\_name field was channel\_x\_partial, the channel\_x\_partial content would appear when the page is viewed in the browser.

The code below has not worked.

```
{exp:channel:entries channel="channel_name" limit="1" dynamic="no" entry_id="{structure:page:entry_id}" disable="member_data|pagination"}
    {partial_name}
{/exp:channel:entries}

```

Am I way off base? Would another type of embed work better? The catch is I need this to be dynamic as different entries would call different partials.

Thank you in advance even if it is to let me know I am way way off base!

Peter T

# Answer
Providing your field short name is `partial_name`, have you tried this syntax?

```
{exp:channel:entries
    channel="channel_name"
    limit="1"
    dynamic="no"
    entry_id="{structure:page:entry_id}"
    disable="member_data|pagination"}

    {{partial_name}}

{/exp:channel:entries}

```

Another option is to just use conditionals based on the field value if that doesn't work:

```
{exp:channel:entries ... }

     {if partial_name == "partial_1"}
         {my_partial_1}
     {/if}

{/exp:channel:entries}

```

Other options are possible but we would need some more info, perhaps some expanded sample template code on what you want to accomplish.
> 0 votes

---
Tags: embeds, template-partials
---


title: Navbar Toggler not working

text:
# Question
Title: Navbar Toggler not working
TROUBLESHOOTING Migrating an old blog over using this templte Bootcamp 4 and EE The navbar toggler is working on the .index template but not on the subsequent templates.

WORKING:

NOT WORKING:

I’m loading jquery.js before bootstrap.js at the bottom of page - so I’ve ruled that out.

Using the same embeds on all templates - so that ticks that box.

Looks like subsequent templates just can’t find the JS folder. Is is an addressing issue?

Anyhow - help appreciated - thanks in advance. S

# Answer
You are using relative addressing for the tag that loads your javascript elements: in the page source you see tags that look like this:

`<script src="V2/js/clean-blog.min.js"></script>`

which will cause the browser to try and load the scripts from a URL relative to the current one the browser is at, rather than the site root.

* In your first example (I corrected the typo in your URL for that one) you are looking at a page in root directory, so the browser goes to the correct location for the javascript resources.
* In your second example, the URL being loaded is not the root directory (it is `/notebook/i_like_jazz`) so the browser goes looking for its resources in the wrong directory (presumably `/notebook/i_like_jazz/V2/js`).

You can fix this by either adding `{site_url}` to the start of the paths to load the javascript from, or simply adding a `/` to the tags - something like:

`<script src="/V2/js/clean-blog.min.js"></script>`

HTH
> 2 votes

---
Tags: ee, navigation, bootstrap
---


# Question
Title: Can't see entry in multiple site mode (EE5)
I have an English language version of the main site installed in multiple site mode (there is no problem with it inside admin panel: I can switch sites, create channels/entries, manage templates for both sites etc.) — en.kiosov.pro. The index page is working well. But I can't see channel page and entries page at all. For example, I have a channel called ***Cases*** with one entry inside. I have a template group called ***cases*** too with 2 templates inside:

***index***

```
{embed="index/header" my_html_class="cases" my_page_title="Cases"}
{exp:channel:entries channel='cases' limit='25' my_active_nav='cases' paginate='bottom' dynamic='no'}
    <div class="blog-entry">
        <h2><a href="{url_title_path='cases/case'}">{title}</a></h2>
        <p>{entry_date format='%n/%j/%Y'}</p>
        <p>{case_teaser}</p>
        {if has_categories}
            <p><b>in</b>: {categories backspace='2'}<a href="{path=/'cases/'}" title="View more in {category_name}">{category_name}</a>, {/categories}</p>
        {/if}
        <p>by: {author}</p>
    </div>
    {if no_results}
        {redirect='404'}
    {/if}
{/exp:channel:entries}
{embed="index/footer"}

```

and ***case***

```
{embed="index/header" my_html_class="cases" my_page_title="Cases"}
{exp:channel:entries channel='cases' limit='1' require_entry='yes'}
    <h1>{title}</h1>
    <p>{entry_date format='%n/%j/%Y'}</p>
    <p>{case_teaser}</p>
    <p>{case_post}</p>
    {if has_categories}
        <p><b>in</b>: {categories backspace='2'}<a href="{path='cases'}" title="View more in {category_name}">{category_name}</a>, {/categories}</p>
    {/if}
    <p>by: {author}</p>
    {if no_results}
        {redirect='404'}
    {/if}
{/exp:channel:entries}
{embed="index/footer"}

```

I have the entries listing code on index page which is works well (you can see it on en.kiosov.pro/#cases page)

```
{exp:channel:entries channel="cases" limit="5" my_active_nav="cases" paginate="bottom" dynamic="no"}
<h3><a href="{url_title_path='cases/case'}">{title}</a></h3>
<h4>{case_teaser}</h4>
{/exp:channel:entries}

```

It builds the correct link to the entry but I get “Not Found” when I click it or just type the link (for example) in the browser URL field. Can’t realize what I missed for en. version because the main site (kiosov.pro — just old design and structure there) works without that problem and I building en. version with the same way (but other channels structure).

Thank you!

# Answer
Here is a solution:

You must copy `.htaccess` file for the second site which works in multiple site mode not just `index.php` and `admin.php` as the documentation says.
> 0 votes

---
Tags: ee5, multiple-sites
---


# Question
Title: How to add a MailChimp Sign Up form for a Newsletter to a website
I am using MailChimp for sending out Newsletters but I would like to add a MailChimp Sign Up form to the website on the Home page.

How do I do this?

I am extremely new to this product so thank you for any help you can provide. Regards

# Answer
We did this in a template in pure html, so we did not use any Expression-Engine-Tags for this (although you might be able to use a form-builder-addon like EEHarbor Forms, but I see no reason for this in the actual case).

The most important ressource you will find in Mailchimp: Select your list, then the "Signup Forms". With "embedded forms" you will be able to generate html-code for a form, different options available.

The form could look somehow like this:

```
<form id="newsletter_form" method="post" action="//yourmailchimpname.us9.list-manage.com/subscribe/post">
    <input type="hidden" name="u" value="checkMailchimpFormBuilder">
    <input type="hidden" name="id" value="checkMailchimpFormBuilder">

    <button value="1" type="submit">Send</button>
    <label for="email" name="email"><b>Email</b>
        <input required="" name="MERGE0" type="email" autocomplete="off" pattern="(.+)@(.+){2,}\.(.+){2,}">
    </label>
</form>

```
> 0 votes

---
Tags: forms, mailchimp
---


# Question
Title: 'default_author' cannot be null' Error when saving channel settings
It is an upgraded site that runs now on EE 5.2.0 without major troubles.

Only when I save channel settings in the CP there is always this error message. Data is saved but this is the message:

```
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'default_author' cannot be null:
UPDATE `exp_channel_form_settings` SET `default_author` = NULL WHERE `channel_form_settings_id` = '1'

```

What do I need to do to get rid of it?

# Answer
> 0 votes
It's a bug. I've noticed it too, in EE4. I actually forgot about and have been too busy to file an issue.

You just have to make sure you select a default author when changing the Channel settings.

I actually don't have a bleeding edge install anywhere, and it looks like the github repo will close bug reports for legacy versions, so would you or anyone else with EE5.2.0 mind filing a bug report on github?

https://github.com/ExpressionEngine/ExpressionEngine/issues/new/choose

---
Tags: control-panel, channel, settings
---


# Question
Title: Update file caching of plug-in from EE2 to EE4
I've been tasked with updating an older EE plug-in that caches Weather Information from Weather Underground. Since WUnderground closed their API a few weeks ago, I've since transitioned the plug-in to open weather map and I've got data coming through properly that I can see on the front end, so all's well there.

The plug-in has some caching functionality where data is cached to reduce unnecessary API calls, but right now I'm having trouble troubleshooting that. Here's a quick example of the code:

```
function fetch_feed( $key, $location, $language ) {

        $parsed_json = FALSE;

        // Check cache

        $cache_path = APPPATH . 'cache/' . $this->cache_name . '/';
        $cache_refresh = $this->cache_refresh * 60; // seconds

        // Check cache folder exists

        if( ! @is_dir( $cache_path ) ) {
            @mkdir( $cache_path );
            @chmod( $cache_path, 0777 );
        }

```

Since the cache that add-ons use has moved from system/expressionengine/cache/ to system/user/cache/ I'm getting an error:

```
Warning fopen(/ee/legacy/cache/weather_forecast/214bc472f656e049d8fcc62458fb70e6):
failed to open stream: No such file or directory

```

I take it I'll likely have to edit the cache path variable, is there a smarter variable to user here aside from '/user/cache/'? My cache folder should have the correct permissions since a number of other add-ons are writing to it without issue.

# Answer
After echoing the entire variable and tweaking the code a bit, I've settled on this:

```
$cache_path = SYSPATH . 'user/cache/' . $this->cache_name . '/';

```
> 0 votes

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


# Question
Title: EE5: How to create or update entries in a custom made module
In EE2 I used the channel entries API to create and update entries. In EE5 I can't use it anymore. The only problem is that I can't find any EE5 API functions to create those entries. Are they gone?

How can I create/update entries in EE5 without using the the legacy channel entries API? I can't find it in de docs.

# Answer
You can still do this:

```
$entry = ee('Model')->make('ChannelEntry', $data);
$entry -> save();

```

Just make sure you have all the required info in the $data array.
> 0 votes

# Answer
You can create and update the Channel Entry using below **Model query**.

**For Creating the Entry :-**

```
$entry = ee('Model')->make('ChannelEntry');
$entry->Channel = $channel;
$entry->site_id =  ee()->config->item('site_id');
$entry->author_id = ee()->session->userdata('member_id');
$entry->ip_address = ee()->session->userdata['ip_address'];
$entry->versioning_enabled = $channel->enable_versioning;
$entry->sticky = FALSE;
$entry->title = $title_url_title;
$entry->url_title = preg_replace("/[\s_]/", "-", $title_url_title);
$entry->entry_date = ee()->localize->now;
$entry->edit_date = ee()->localize->now;
$entry->save();

/* Array which contains your Field Data */
$entry->set($entryFieldArray);

```

**For Updating the Entry :-**

```
$entry = ee('Model')->get('ChannelEntry', $id)
        ->with('Channel')
        ->filter('site_id', ee()->config->item('site_id'))
        ->first();

/* Array which contains your Field Data which need to update */
$entry->set($entryFieldArray);

```
> 0 votes

---
Tags: module, ee5
---


# Question
Title: How can I get "total_results" number of entries filtered using the parents tag?
I have a channel entries tag that displays one entry form the "markets" channel. Within that, I want to display article entries. The "articles"(parent) channel has a relationship field to select which "markets"(child) entry. But, I have other channels that also have a relationship field pointing to "markets" entries. So when I use the code below to display "parents" from a specific channel and field, it works fine. BUT, if that results in 3 entries being returned, the parents\_total\_results tag doesn't return 3, it returns a higher number. Is there any way to get a number of the entries returned from the parents tag?

```
{exp:channel:entries channel="markets" disable="categories|member_data|category_fields|pagination" sort="asc" limit="1" dynamic="yes" require_entry="yes"}
        {parents field="articlemarket" channel="articles" limit="3" sort="desc" orderby="date"}
        {parents:total_results}
        {/parents}

```

# Answer
I'm wondering if it's a bug. As your results total is 8, are there actually 8 parent entries across channels/entries for this particular entry?

Try this code, should pull in all parent titles:

```
{parents}
{parents:title}<br>
{if parents:count == parents:total_results}
 Total: {parents:total_results}
{/if}
{/parents}

```
> 1 votes

# Answer
Mike have you tried removing the field= parameter? you shouldn't really need it unless you're pulling data from multiple relationship fields in the articles channel.

```
{parents channel="articles" limit="3" sort="desc" orderby="date"}
{parents:total_results}
{/parents}

```
> 0 votes

---
Tags: relationships, parent
---


# Question
Title: Expresso store : add on, hook store_order_complete_end creates order id+1
Expression Engine 2.10.1 , Expresso Store 2.5.1

For enabling payment via Klarna we have used following Hook to create a custom add-on to handle order creation via API.

https://www.exp-resso.com/docs/extension\_hooks.html store\_order\_complete\_end

The API connection is succesfull however after order completion we get some strange behavior:

An order ID is created, but after the hook is called the order ID get +1 on the order id (e.g original order 451 becomes order 452).

# Answer
Using `$this->extensions->last_call` in the hook turned out to be redundant.
> 1 votes

---
Tags: expresso-store, add-on-development, hook, orders
---


# Question
Title: Channel Images field messing up display of channel form
EE 4.3.8 Channel Images 7.1.0

I have a channel form that contains a Channel Images field. But this field is causing the entire output of the template to be wrapped in a `<pre>` tag pair which messes up the display of the entire page.

```
 <fieldset class="reqborder" style="display:block; float:left; clear:left; width:95%; margin-bottom:15px">
    <legend  ><strong>Photo of Applicant</strong></legend>
                <div class="clearfloat" style="margin-bottom:12px"></div>
    <label for="headshot" style="font-weight:normal"><span class="reqbold">Headshot <span class="req">* Required </span></span>
      Upload -one only- recent photo of yourself. If you have an actor headshot/resume, upload that. Monologue Workshop & On-Camera Audition require a current acting headshot/resume to be uploaded here, and one presented at the interview.</label>
                     <div class="clearfloat" style="margin-bottom:22px"></div>

 <div>  {field:headshot}</div>
            <div class="clearfloat" style="margin-bottom:12px"></div>

           </fieldset>

```

# Answer
Problem is caused by known bug.

Temporary fix:

Edit the `system/user/addons/channel_images/ft.channel_images.php` file and remove the `echo '<pre>';` on or around line 121, that should solve that issue.
> 0 votes

---
Tags: safecracker, channel-images
---


# Question
Title: ExpressionEngine htaccess with password protected subdomain
I have inherited an ExpressionEngine site and need to add a password-protected subdomain. The original htaccess file in the root directory was...

```
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Removes index.php from ExpressionEngine URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

    # Directs all EE web requests through the site index file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>

```

...but when password protection was added to the subdomain, users could click "cancel" and then the page contents would become visible.

I added...

```
RewriteCond %{HTTP_HOST} !^mysubdomain\. [NC]

```

...to the second rewrite rule, and that allowed the password protection to work normally for the subdomain homepage; however, none of the pages or subdirectories in that subdomain work now. It looks like all the page resources are getting URLs like: "http://mysubdomain.domain.com/{site\_url}images/uploads/core-images/image.png"

How can I get the password protection working properly without breaking the URLs so that the rest of the subdomain pages and subdirectories will work properly?

# Answer
After much searching, we abandoned the htaccess route and went with EE's template access restrictions: https://devot-ee.com/articles/item/using-ee-built-in-http-authentication-for-restricting-development-access.
> 0 votes

---
Tags: htaccess, subdomain
---


# Question
Title: Freeform not pulling some answers into notifications
Have an issue where I have added check boxes and radio buttons to a form but am having the results pull into the notification email correctly. Two Questions....

1. The check boxes are needed to allow "check that all apply" for the user. However, in the notification email is only showing the last item checked on the email. So if a user checks Regional Driver, Local Driver and Warehouse...only Warehouse shows up on the form. Here is the code I have for that...

How do I get the multiple selections to pull into the notification form?

> Interested In (Check All That Apply)
>
> OTR Driver/Regional Driver
>
> Local Driver
>
> Packer/Loader/Unloader
>
> Warehouse

2. Likewise, on my radio buttons it isn't pulling in the selection of Per Hour, Per Week, Per Month or Per Year into the from. It is only showing the entry entered into the Salary Expectations box. I have fields set up for "salary\_expectations" and for "pay\_rate". How would I tie the radio buttons to the pay\_rate field so that it pulls into the notification form?

> What are your salary requirements?
>
> Per Hour
>
> Per Week
>
> Per Month
>
> Per Year

Just in case the code isn't showing properly on here, I am adding a screenshot.

# Answer
For #1, the issue is that you need to specify `[]` on the checkbox field names to accept more than one:

```
<input type="checkbox" name="interested_in[]" value="OTR Driver/Regional Driver" />

```

For #2, judging by the way you wrote your question and the screenshot of code (next time would be nicer to just include the actual code btw), I assume this is because you have the wrong field name specified. In your question you say the field is named `pay_rate`, but your template code uses `help_packing`.
> 1 votes

---
Tags: solspace-freeform, email, notification, checkbox
---


# Question
Title: While viewing entry in CP, can a generate a link to view it on the web?
While viewing an entry in the control panel, can I generate a link that would open it in my public website? That is, display a link like "www.mysite.com/articles/{url\_title}"?

Using EE3, but can update to 5 if needed.

# Answer
If I understand the question, then except under very specific circumstances the answer is probably 'no'. The reason goes to the heart of how EE works. EE separates the storing of data from the generation of HTML output to your website - data is stored as entries in channels, but there is no strict association between these channels and what appears on your site: indeed EE is rich in elements that allow you to build templates that output pages that are built from complex association of the data drawn from multiple channels and multiple channel entries.

Accordingly when you are looking at an entry in EE CP, there is no particular reason to think that that entry will itself generate a page of output - so the idea that you can have a link that will display the output is not always so meaningful. Further, given this separation of design, output and content, it is usually not possible to tell from a single entry where it will be output by the site - indeed one entry may appear on multiple pages.

The only exceptions to this are as follows:

* You have designed your site to map single entries to single pages, either by manually building a set of site templates that does this, or using a commercial add-on such as Structure that basically simulates the style of site construction you would see in Wordpress;
* Your entry contributes to just one page in the site - but is part of many other elements that also contribute to the page - EE won't know what this page is, or what the other elements are, but you might.

The key component in both these examples is that EE doesn't know what page the entry will link to - but you do: so the only sensible solution to your question is for you to answer it yourself for each entry you edit.

HTH
> 1 votes

# Answer
I ended up messing with the control panel code to generate this link. For anyone who'd like to make a link based on an entry's content in the edit entry interface, here's what I did.

File: system/ee/EllisLab/ExpressionEngine/View/publish/entry.php

Line: 133 (EE 3.5.16), right after the $field-\>getLabel() call

```
<?php
                            if ($field->getLabel() == "Your Label Value") {
                                $form = $field->getForm();
                                preg_match('/value="(\w*)"/', $form, $form_value);
                                echo " - <a href='http://www.site.com/" . $form_value[1] . "' target='_blank'>Go to link</a>";
                            }
?>

```
> 0 votes

---
Tags: control-panel
---


# Question
Title: Update EE Maps by Reinos height & redraw on button click
I'm in the process of transitioning a site from an older version of Objective HTML Gmaps to EE Maps by Reinos and I'm having trouble with one feature that the older Gmaps (or perhaps the Google Maps API) made quite easy.

When clicking on a "more map" button on the map, the map was redrawn and resized based on the larger height 150px \<-\> 400px. This was accomplished with:

```
google.maps.event.trigger(placesmap, 'resize');

```

With EE Maps, I'm struggling to make this same behavior happen. If anyone has any experience with this I'm at a loss. I've also given the updateMap EE Maps API call a go

```
EE_MAPS.api('', {
  mapID : 'ee_map_1',
  options: {height : '400px'}
});

```

But this likewise doesn't do anything. You can see the behavior on this page.

# Answer
> 0 votes
To those in the future that find this question, you can now "refresh" the map with the follow JS:

```
EE_MAPS.api('refresh', {
  mapID : 'ee_map_1',
});

```

Make sure to change ee\_map\_1 to whatever your map ID is if you changed it!

---
Tags: add-on, google-maps, ee4
---


# Question
Title: Using DataTables to query a set amount of records, not all records
I have a webpage that utilizes Expression Engine for it's backend. One of the pages is taking 3-5 seconds to load because it is querying for all records in a channel and displaying them in a Datatable (for more info on this JS lib, see: https://datatables.net/).

How would I use Ajax to query for only 50 records at a time instead of having Datatables or EE query ALL of the records? I want to optimize this to bring down the load time and prevent it from getting worse as more records are added to the table.

As of now, this is the JS that creates the Datatable:

```
$('#server_table').DataTable( {
        "pageLength": 50,
        "lengthMenu": [[10, 50, 100, 500], [10, 50, 100, 500]],
        "order": [[ 0, "asc" ]]
}

```

Here is how EE constructs the table's body:

```
<tbody>
   {exp:channel:entries channel="servers" limit="3000" status="Open|Closed"}
   <tr>
   {if status == "closed"}
   <td><a href="{url_title_path='site/server_detail'}" class="text-danger">{title} (Decomm'd)</a></td>
   {if:else}
   <td><a href="{url_title_path='site/server_detail'}" class="text-navy">{title}</a></td>
   {/if}
   <td>{server_ip_address}</td>
   <td>
{server_application}
    <a href="{siteurl}index.php/site/system_detail/{server_application:url_title}" class="text-navy">{server_application:title}</a>{if server_application:total_results > 1}<br>{/if}
{/server_application}
    </td>
    <td>{server_environment}</td>
    <td>{server_operating_system}</td>
    <td>{server_data_center}</td>
    </tr>
    {/exp:channel:entries}
 </tbody>

```

# Answer
> 0 votes
To achieve the speed up you are looking for you ideally need to modify your use of datatables such that it pulls just the information it needs to render the currently visible 50 rows, rather than pulling the entire dataset before you render the table.

This issue is quite common, and Datatables has a rich feature set to support various strategies to enable this type of working: from defering the loading of the bulk of a large dataset until after the initial view of the table has been rendered, to multiple approaches for AJAX access to partial data sets.

How you configure datatables to deliver your required results is outside the scope of this forum (but there are very good support options to help you with this via the datatables site). But the EE configuration to support these options is disarmingly easy.

The simplest datatables solution to implement is probably deferred loading - which means you continue to dump the entire dataset out on first contact each time, but the bulk of the loading delay is hidden from the user. If this is what you are doing, you probably want to turn on EE's quite effective caching system - which may give you a useful speedup (for the hidden dataload). There are a few options for how you enable the caching options for EE, and a clearly written part of the EE documentation takes you through the options and their pros and cons.

Depending your server configuration it is possible that you can achieve quite impressive speed-ups by turning caching on: 3000 records is (quite possibly) a small amount of data compared to (say) a large picture, and so reading this from a file rather than your database server each time might be all you need to do to get OK performance - particularly if you couple it with deferred loading in the table. An example of what your channel:entries tag might look like with simple caching turned on would be:

```
{exp:channel:entries
    channel="servers"
    limit="3000"
    status="Open|Closed"
    cache="yes"
    refresh="3000"}

```

As the documentation notes, another speed up might be able to use is to disable parts of the EE query using the `disable` parameter. With this your tag becomes something like:

```
{exp:channel:entries
    channel="servers"
    limit="3000"
    status="Open|Closed"
    cache="yes"
    refresh="3000"
    disable="categories|custom_fields|member_data|pagination"}

```

The better solution would be to change how your table rendering works so that datatables is fed with 'just enough' information for the table render the part of the dataset that is visible for the current page of the table (i.e. send just 50 records at a time). Providing the restricted data sets for this kind of operation from within EE itself is disarmingly easy - no more complex than adding two more parameters to the call: **limit** and **offset**. You are already using **limit** (to override the default limit on records returned). **offset** simply sets the index from which you want to retrieve records. What's more the same caching speedups we discuss above can be applied too...

So to return just 50 records from an arbitary point (e.g. in this case to return records 51-100) from your channel you could use a call like:

```
{exp:channel:entries
    channel="servers"
    limit="50"
    offset="50"
    status="Open|Closed"
    cache="yes"
    refresh="3000"
    disable="categories|custom_fields|member_data|pagination"}

```

To make this approach work you almost certainly need to generate this restricted dataset in response to AJAX calls. From the EE perspective this is not difficult to implement - simply create a specific template to deliver the table data in whatever format you require it for the datatables instance (for example JSON) and then set the **offset** and **limit** values in that template set via either URL segments, GET or POST data (it doesn't really matter which - since the URL is not one that anyone sees). For example if you used URL segments your AJAX url would perhaps look like this:

NB. assumes the ajax template is at **/data-provider/** with **offset** first, **limit** second and that on this call you want the 50 records following the 250 entry ():

```
https://your-domain.com/data-provider/250/50

```

The matching channel:entries tag for this would look something like:

```
{exp:channel:entries
    channel="servers"
    limit="{segment_3}"
    offset="{segment_2}"
    status="Open|Closed"
    cache="yes"
    refresh="3000"
    disable="categories|custom_fields|member_data|pagination"}

```

Hope this helps with the EE side of the problem - if you are stuck on configuration of datatables, better to ask questions of their support community if you can.

---
Tags: javascript, ajax, html
---


# Question
Title: Split Channel Entries via {exp:channel:entries}
I have only recently started working with ExpressionEngine and am currently trying to port my HTML page and work with channels. I just came across a problem that I can't solve. I want to split the entries of a channel into two columns.

The code to display the same entries in both columns currently looks like this:

```
<div class="row">
    <div class="col-md-6">
        {exp:channel:entries channel="portfolio"}
            <div class="cc-porfolio-image img-raised" data-aos="fade-up" data-aos-anchor-placement="top-bottom">
                <a href="#web-development">
                    <figure class="cc-effect">
                        <img src="{image}" alt="Image" />
                        <figcaption>
                            <div class="h4">{title}</div>
                            <p>{aufgabe}</p>
                        </figcaption>
                    </figure>
                </a>
            </div>
        {/exp:channel:entries}
    </div>
    <div class="col-md-6">
        {exp:channel:entries channel="portfolio"}
            <div class="cc-porfolio-image img-raised" data-aos="fade-up" data-aos-anchor-placement="top-bottom">
                <a href="#web-development">
                    <figure class="cc-effect">
                        <img src="{image}" alt="Image" />
                        <figcaption>
                            <div class="h4">{title}</div>
                            <p>{aufgabe}</p>
                        </figcaption>
                    </figure>
                </a>
            </div>
        {/exp:channel:entries}
    </div>
</div>

```

What adjustments are necessary to make it possible to display half of the entries in the left column and the other half in the right column?

Thanks

# Answer
> 2 votes
Given that your code duplicates the same HTML for each column, there is also a way to do this simply using Bootstrap to generate the columns (it looks like you are using Bootstrap from your code sample). Using bootstrap to do the layout makes your template code easier to manage and reduces the number of transactions between your browser and EE - which all else being equal are probably good things to aim for.

There are lots of options for how you might do this using Bootstrap 4 - here is one to illustrate:

```
<div class="row">
    <div class="d-inline-flex flex-wrap">
        {exp:channel:entries channel="portfolio"}
        <div class="col-md-6">
            <div class="cc-porfolio-image img-raised flex-fill" data-aos="fade-up" data-aos-anchor-placement="top-bottom">
                <a href="#web-development">
                    <figure class="cc-effect">
                        <img src="{image}" alt="Image" />
                        <figcaption>
                            <div class="h4">{title}</div>
                            <p>{aufgabe}</p>
                        </figcaption>
                    </figure>
                </a>
            </div>
        </div>
        {/exp:channel:entries}
    </div>
</div>

```

Enjoy!

# Answer
> 0 votes
Here is an example that outputs ten entries in one Channel Entries loop, and then the following ten entries in the second:

```
{exp:channel:entries
    channel="portfolio"
    limit="10"}

    {title}<br/>

{/exp:channel:entries}

{exp:channel:entries
    channel="portfolio"
    limit="10"
    offset="10"}

    {title}<br/>

{/exp:channel:entries}

```

**Edit**

Here is an example that makes it dynamic to split the entries in half in one Channel Entry loop:

```
{exp:channel:entries
    limit="11"}

    {if count < total_results / 2}
    <p>
        left - {title}<br/>
    </p>
    {if:else}
    <p>
        right - {title}<br/>
    </p>
    {/if}

{/exp:channel:entries}

```

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


# Question
Title: Siblings with entry_id not in another relationship field
Can't figure this out.

I'm using EE2 and I have a channel called products and I'm on a single product page. I have a relationship field for products set up called featured\_products, which I am displaying in a list. I can do that fine. They're basically related products.

I, then, want to have a see more button that displays another list of ALL other products (siblings), EXCEPT that list should exclude the ones that are already in featured\_products.

I tried using siblings, to no avail:

```
{siblings
    entry_id="not {entry_id}
              {featured_products}
                 |{featured_products:entry_id}
              {/featured_products}"
}

```

and that didn't work because I guess "field" is the only siblings arg.

I tried using an embed and doing something like:

```
{embed="products/.more-products"
    notproducts="
    {entry_id}
    {featured_products}
        |{featured_products:entry_id}
    {/featured_products}"}

```

and then in that embed had something like

```
{exp:channel:entries channel="products" entry_id="not {embed:notproducts}"}
{/exp:channel:entries}

```

which for reasons I can't understand, only showed one product, the product whose page I was on.

Pretty sure I'm just approaching this wrong. HALP!

# Answer
> 0 votes
Your embed solution should work, but you probably need to add `dynamic="no"` to the channel entries call (see docs).

HTH

---
Tags: ee2, channel-entries
---


title: HTTPS url just redirects back to HTTP

text:
# Question
Title: HTTPS url just redirects back to HTTP
I have a site that's running EE 3.3 and I'm trying to change it to include the SSL certificate that's just been installed on the server.

I normally can change the config or the URL settings to include the https and then update the .htaccess to force https on all the urls. However when I try this the site just gets caught in a loop.

I've tried removing everything out of the .htaccess and then trying but it then redirects back to the http.

I've also set up a plain html test page outside EE and I can access that if I go to it but if I then visit the website and then go back to the test page it redirects back to the homepage.

Going round in circles so would appreciate any help.

Thanks in advance.

# Answer
> 0 votes
Did you check your config.php files fo any url config? Maybe there's something overwriting the url and path settings in the cp?!

# Answer
> 0 votes
To overcome this issue very first thing you need to do is to change URLs `(with https)` from Admin Panel `(Settings >> URL and Path Settings)`. Make sure there should no hardcoded URL in `config.php`. Then you should add below code in your `.htaccess` file.

```
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

```

---
Tags: htaccess, config, redirects, ssl, server
---


# Question
Title: Telling Structure to ignore a URL segment
I'm a little rusty with how Structure handles URL segments, so hopefully someone here can help. I'm using Structure on a site to handle all of the page management. One of the Structure-managed pages has a form on it:

https://www.domain.com/form/

I've code the form so that upon a successful submission, the user should be redirected to another Structure-managed page:

https://www.domain.com/form/thanks/

However, the form add-on that I'm using automatically appends another segment to the success URL, like so:

https://www.domain.com/form/thanks/9b67c74423314c9dr04dcx6210032052

That last segment is dynamically generated for each form submission by the form add-on. However, as far as Structure is concerned, that additional URL segment is a non-existent page and so it returns a 404.

Is there a way to "trick" Structure into basically ignoring that last URL segment altogether and instead, just displaying https://www.domain.com/form/thanks/?

The site in question is using EE4 (and will be upgraded to EE5 soon) and Structure v4.4.4.

# Answer
> 0 votes
You could have a look at freebie: https://addons.reinos.nl/freebie set it to ignore all segments after "thanks"

---
Tags: structure, ee4, ee5
---


title: Not seeing alt tag content for images

text:
# Question
Title: Not seeing alt tag content for images
Is there accessibility improvements with the latest version of EE?

Currently our site doesn't have alt content for images. Wouldn't this be covered in the file upload process or shouldn't this be a field on the admin page when adding an image to a page.

# Answer
You could create in the Field Manager of the Control Panel an 'alt' channel Field, and place it inside your template.

```
{exp:channel:entries channel="test" limit="10"}
    <img src='image.png' alt='{my_alt_field}' >
{/exp:channel:entries}

```
> 1 votes

# Answer
as Stephane said. This gives you the added SEO benefit that you can change the alt text for each page where you use the image. Same goes for links, i normally create a link title field whenever there's a link field.
> 0 votes

---
Tags: image
---


# Question
Title: EE 5 - Code snippet in template appearing and disappearing on website
I have an code snippet embedded in one of my pages, that will disappear, and then, if I go into EE, open the template, see that *yes* it is there, and close the template, then it’s there again on the website. So weird.

Page: https://brookechao.com/about

It’s a website content reader. When it shows up, it’s an orange button right next to the heading text of the page.

The code is this:

```
<script async src="https://widget.websitevoice.com/wBI4odpYGBtGcKfXUCgasg"></script>
<script>
  window.wvData=window.wvData||{};function wvtag(a,b){wvData[a]=b;}
  wvtag('id', 'wBI4odpYGBtGcKfXUCgasg');
  wvtag('gender', 'female');
  wvtag('text-selector', 'article, .post-content, .blog-body, .post_content, .content, .section,.wsv-audio');
  wvtag('widget-style', {
    className: 'wv-circle-small',
    backgroundColor: '#F5953E',
    tooltipText: 'Audio Version of Content'
  });
</script>

```

# Answer
> 1 votes
I figured it out. That include was a copy of another include, and so permissions were reset to none. Meaning no one could see it, but if I logged in to check the templates involved, suddenly it would reappear (because I was logged in as a SuperAdmin).

Setting the permissions seems to have fixed the issue.

---
Tags: embeds, ee5
---


# Question
Title: Unable to change sites in cp - logs out admin
EE 2.8.1 with MSM (4 sites)

We've duplicated our production site to a development local environment. Same server configuration, with the exception of some path info. Production server and site is running fine, but we're redesigning the site, and don't want to work on production.

So, on our DEV side:

Each of the sites (subdomains) work and I can view each of the subdomains from a 'visitor' view which tells me all looks good from the outside world, and I can log in to the default\_site.

However, when I attempt to change to one of the other sites in CP, it logs me out and redirects to the admin login form.

At this point, I am unable to login, as it throws no error in the logs, and simply redisplays the login screen.

Cleared browser cache/cookies, and I can login to the main site, but not access any other sites through CP.

I've read through several different listings and posts here, and on the EE dev forum. I've tried all the $config tricks and tickles, to no avail.

Checked all the paths to make sure they're correct in index.php/admin.php In the exp\_sites table, I've even checked all the serialized data to verify all is good there for each of the sites.

I'm fairly new to EE, and understand 2.8.1 and MSM are having some issues. If anyone has found other helpful things to look at, or poke, I would appreciate the responses!

UPDATE:

EE 2.8.1 with MSM Sites 2.1.5

Despite all attempts to track down the issue, I am still unable to change sites within CP. When the redirect occurs, it sends back to login screen, and without clearing my browser cache/cookies, it will not allow admin to login.

I can login to the main site (after flushing browser cookies) and can do everything in the main site.

Perhaps it is an issue with 2.1.5 MSM and 2.81 EE?

/system/expressionengine/config/config.php:

```
$config['app_version']                  = '281';
$config['license_number']               = "xxx-xxxx-xxxx-xxxx";
$config['multiple_sites_enabled']       = "y";
$config['index_page']                   = "";
$config['debug']                        = '1';
$config['cp_url']                       = http://url.tomycontrolpanel.net/admin.php';
$config['is_system_on']                 = "y";
$config['disable_csrf_protection']      = "y";
$config['cookie_domain']                = ".mydevdomain.com";
$config['cookie_httponly']              = "";
$config['cookie_path']                  = "";
$config['cookie_prefix']                = "";
$config['admin_session_type']           = "s";
$config['user_session_type']            = "c";
$config['require_ip_for_login']         = "n";
$config['secure_forms']                 = "n";
$config['cp_session_ttl']               = 14400;
$config['user_session_ttl']             = 3600;

```

With this config I am able to login to my default site CP, but I get logged out when changing to any site within my list of sites.

**Update-\>Updated:** With MSM, be sure you have correctly set $assign\_to\_config variables in your index.php file for main site:

```
 $assign_to_config['site_name']  = 'site_short_name';
 $assign_to_config['cp_url'] = 'webURL_to_control_panel';
 $assign_to_config['site_url'] = 'webURL_To_website';

```

# Answer
It sounds like your cookies may be trying to set for the production domain on the other MSM Sites instead of whatever your dev environment is setup as. Check your Cookie Settings. Since you are unable to log in to the control panel on the other Sites, you may need to use the config override so that it will be applied to each Site.
> 0 votes

# Answer
I have had this happen before. The cause is that some of the other MSM sites do not have the same security settings as the main site. i. e. default\_site is set to use cookies, while site #2 uses cookies and sessions. Until they were all configured the same, switching sites kicks you out.
> 0 votes

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


# Question
Title: Api_channel_fields - cannot add group id
I'm trying to add a new field to a group using the API but it doesn't work (according to the docs it is supposed to be a key).

I have tried running the example code but the 'group\_id' field is ignored when I add it to the field object sent to the update\_field method:

```
        ee()->load->library('api');
        ee()->legacy_api->instantiate('channel_fields');
        $field_data = array(
            'site_id' => 1,
            'group_id' => 1,
            'field_name' => 'aaaa',
            'field_label' => 'AAAA',
            'field_type' => 'text',
            'field_order' => 10,
            'field_required' => 'y',
            'field_search' => 'y',
            'field_is_hidden' => 'n',
            'field_instructions' => '',
            'field_maxl' => 128,
            'text_field_fmt' => 'none',
            'text_field_show_fmt' => 'n',
            'text_field_text_direction' => 'ltr',
            'text_field_content_type' => 'all',
            'text_field_show_smileys' => 'n',
            'text_field_show_glossary' => 'n',
            'text_field_show_spellcheck' => 'n',
            'text_field_show_file_selector' => 'n',
        );

        ee()->api_channel_fields->update_field($field_data);

```

So I added a call to field\_edit\_vars prior to the update\_field call as stated in the docs:

```
    $vars = ee()->api_channel_fields->field_edit_vars(1, FALSE);
    ee()->load->view('admin/field_edit', $vars, TRUE);

```

But I get 'Call to undefined method Api\_channel\_fields::field\_edit\_vars()'

I've also tried using the return value from the 'update\_field' method, which according to the docs should be the new field id but it returns nothing.

How do I add the new field to a group?

# Answer
As far as I know there is no way to do this using API. I think you should try with **EE Model**. You can easily create new `field` using the Model. And Model is most effective way to handle all these core things.

You can create new field using below **Model** code.

```
$field = ee('Model')->make('ChannelField');
$field->site_id = 0;
$field->field_name = 'your_field_name';
$field->field_label = 'Your Field Label';
$field->field_type = 'text';
$field->field_pre_populate = 'n';
$field->field_ta_rows = '6';
$field->field_maxl = '256';
$field->field_required = 'n';
$field->field_text_direction = 'ltr';
$field->field_search = 'n';
$field->field_is_hidden = 'n';
$field->field_fmt = 'xhtml';
$field->field_show_fmt = 'n';
$field->field_order = '10';
$field->field_content_type = 'any';
$field->field_settings = '';
$field->legacy_field_data = 'n';
$field->save();

```

**To create Select field :-**

```
$field = ee('Model')->make('ChannelField');
$field->site_id = 0;
$field->field_name = 'my_dropdown';
$field->field_label = 'My Dropdown';
$field->field_type = 'select';
$field->field_pre_populate = 'n';
$field->field_ta_rows = '6';
$field->field_maxl = '';
$field->field_required = 'n';
$field->field_text_direction = 'ltr';
$field->field_search = 'n';
$field->field_is_hidden = 'n';
$field->field_fmt = 'xhtml';
$field->field_show_fmt = 'y';
$field->field_order = '10';
$field->field_content_type = 'any';
$field->field_settings = '';
$field->legacy_field_data = 'n';
$field->save();

```

I hope this code will work for you. I have added code to create select field.
> 1 votes

---
Tags: custom-fields, api
---


title: Json output is not right

text:
# Question
Title: Json output is not right
I have in EE a json file that pull the file name (file\_name@2x.jpg) from de database where the name is ok but the output is file\_name%402x.jpg

how can I fix that?

```
{exp:channel:entries channel="json" disable="member_data|paginate" dynamic="off" orderby="hotspot" sort="decs" category="3"}{
    "id": {entry_id},
    "foto_groot": "{foto_groot}{file_name}{/foto_groot}",
    "titel": "{title}",
    "url_ext": "{url}",
    "url_int": "{url_title_path=/}",
    "categorie": "{categories}{category_name}{/categories}",
    {if {current_time format="%U"} - {entry_date format="%U"} < '2500000'}"flagsn":{"nieuw":true },{/if}
    "flags":{"new":{hotspot}} }{if count==total_results}{if:else},{/if}{/exp:channel:entries}
]
}

```

# Answer
> 2 votes
You can use variable modifiers. Check https://docs.expressionengine.com/latest/templates/variable-modifiers.html#variable-modifiers

```
{filename:json}

```

# Answer
> 1 votes
If I use {file\_name:json} it add qoutes to the begin and end but did not chance the %40 into @. Use url decode to fix the problem. Thanks

---
Tags: json
---


title: EE Maps search tag migration change

text:
# Question
Title: EE Maps search tag migration change
I'm updating to EE Maps from the older version of the plugin and I'm trying to figure out the comparable replacement for the {exp:gmap:search} tag. Does the update require me to use the JS API search? or is there another way to do it?

The current code looks like the following:

```
{exp:gmap:search
                        channel="distributors"
                        geocode_field="location"
                        latitude_field="latitude"
                        longitude_field="longitude"
                        distance_field="distance_max"
                        cache_post="false"
                        return="/page"}
                    <input id="h-dist" type="hidden" name="distance_max" value="500"/>
                    <input id="h-search" type="search" name="location" placeholder="Search"/>
                    <input type="hidden" name="status[]" value="open" />
                        <input type="submit" value="Find X">
                    {/exp:gmap:search}

```

The new code doesn't allow for just switching out the tags.

# Answer
My comment was correct. Using the search example below you should be able to get everything you need for this to migrate successfully. If you need to work with post variables you're going to need to submit the data you need before you submit the search form because it is cached to a search result query. I ended up pushing a local storage variable through AJAX to a session to get what I needed.

https://docs.reinos.nl/maps-locator/examples.html#search-example
> 0 votes

---
Tags: google-maps-for-ee, objective-html
---


# Question
Title: Trying to add a Captcha to a form created in FreeForm
First time posting. Did a cursory search on this subject but didn't find what I was looking for. If the answer is already in another thread, feel free to redirect me there and I will read it very carefully!

The organisation I work for, a non-profit called Volunteer Bénévoles Yukon, uses ExpressionEngine for our website hosted at volunteeryukon.ca. We have a contact form (created with Freeform Pro 4.2.2) at this URL http://volunteeryukon.ca/contact/. It's been there for years without any sort of CAPTCHA and it wasn't an issue, but over the last 6 months or so, the amount of spam messages we've received through it have triggered us to look for ways to reduce such.

Initially, I thought to add a CAPTCHA to the form, and in ExpressionEngine, when I navigate to Forms -\> Composer (for said form), which takes me into Freeform Pro 4.2.2, I was able to add a Captcha above the Send button on the form. I saved, came back in the same way, and confirmed the Captcha addition took. But... when I browse back to the contact form as an anonymous browser, there is no Captcha showing up, and the form can still be filled out by anyone for anything (including, it would seem, spam bots).

I tried to click on Help (in the same menu bar as Forms) but it takes me to a "Whoops! (a.k.a. 404 Not Found)" (the URL is https://docs.expressionengine.com/latest/cp/add-ons/module\_manager.html).

I'm not sure what steps I might be missing. The form looks right (with the added CAPTCHA) in Composer / Freeform Pro 4.2.2, but the Captcha just isn't showing up on the actual form browsers view. Help?"

# Answer
I know it is an indirect solution, but you might find it better all around to solve this a different way, by installing snaptcha \- a truly excellent utility. There is almost no installation (simply install and enable the add-on and it will do the rest) and no captcha box to worry about - 'it just works'.

The add-on has a small fee.

Have used it in the past on a Freeform Pro form and it works fine with the add-on - when we installed it spam was eliminated, simple as that.

HTH
> 1 votes

---
Tags: solspace
---


# Question
Title: EE google maps not displaying on contact page
we have taken over an EE page from another guy www.fitnesscoach.lu in the "contact-area" the google maps is not showing anymore any indication where i can find it in the backend and how to fix tks

# Answer
There's many possibilities!.. Which EE version are you using? (I check the admin login and it looks like you have EE 2.x

1. The code is "hard coded" in the template.
2. They put the google map code in a Variable OR an snippet
3. They use an Addon..

But as i can see the problem is that the Map was in the "MyMap" developer account and he deleted it...

If you need more help let me know..
> 0 votes

---
Tags: channel
---


# Question
Title: Unable to load the requested class: cartthrob_loader
Want to checkout as a guest. No login.

On EE 5 and Cartthrob 4.2.

When I send the checkout\_form I get this error

```
Unable to load the requested class: cartthrob_loader

```

What might cause this error?

# Answer
> 0 votes
This was fixed with version 4.3.

---
Tags: cartthrob
---


# Question
Title: Ordering/sorting channel entries by Calendar date
I have a channel (event) that is being used to display 'events', which is being ordered on the page by a date field (e\_date).

I have now added Solspace Calendar (e\_calendar) as a new field to replace the existing date (e\_date) and time (e\_time) fields.

Below is my channel:entries code, with the updates to display the (e\_calendar) date and time.

What I want to know is how how do I get the events to order/sort - so the next upcoming event appears first, etc.

```
{exp:channel:entries channel="event" limit="4" sort="asc" orderby="e_date" dynamic="no"}
<div class="hevent">
    <div class="{switch='hedate1|hedate2'}">{e_calendar}
        <div class="day">{calendar:event_start_date format="%l"}</div>
        <div class="date">{calendar:event_start_date format="%j"}</div>
        <div class="month">{calendar:event_start_date format="%M %Y"}</div>{/e_calendar}
    </div>
    <div class="hecont">
        <h4>{title}</h4>
        <p>{e_summary}</p>
    </div>
    <div class="hecont">
        <p><i>{e_calendar}{calendar:event_start_date_timestamp_utc format="%g:%i%a"} to {calendar:event_end_date_timestamp_utc format="%g:%i%a"}{/e_calendar}</i>
        <br>{e_location}</p>
    </div>
</div>
{/exp:channel:entries}

```

I have tried a few things but cannot seem to work it out.

ANY HELP is appreciated!

# Answer
> 0 votes
The documentation for **Solspace Calendar** suggests that you should be using the add-on's **Calendar Events** tag to do this.

HTH

---
Tags: solspace-calendar, orderby, sort
---


# Question
Title: Issue with fluid fields and conditionals
I have migrated a channel to using a fluid field instead of the old setup of one body field and one extended text field. The fluid field includes a textarea and a grid field that of course can be used any number of times each.

I managed to sort out that the index displays only the first instance of the textarea and the first instance of the grid field even if there are more. I do that like this:

```
{westeros_content}

{westeros_content:westeros_text}
{if {westeros_content:count name="westeros_text"} == "1"}{content}{/if}
{/westeros_content:westeros_text}

{westeros_content:westeros_image}
{if {westeros_content:count name="westeros_image"} == "1"}
{content}
<div class="EntryImage">
<a href="http://{content:file}">{content:image:medium}</a>
</div>
{content:caption}
{/content}
{/if}
{/westeros_content:westeros_image}

{/westeros_content}

```

However, I would also like to offer a “read on” link IF there us more than one text field, and I can’t seem to figure out how to construct that. What I tried was this:

```
{if {westeros_content:count name="westeros_text"}  > "1"}
<div class="EntryExtended"><a href="http://{comment_url_title_auto_path}">read on >></a></div>
{/if}

```

And that gives me the following error:

```
Error
You have an invalid conditional in your template. Please review your conditionals for an unclosed string, invalid operators, a missing }, or a missing {/if}.

Parser State: Invalid Condition: Not enough operands for operator ” > “.

In Template “Announcements/index” on line 90

```

Removing the inner curly brackets also do not work, so I can’t quite figure out what I am missing here.

# Answer
> 2 votes
Put quotes around the first half of your conditional, and change the inner quotes to single quotes (to stop EE parser getting confused) - something like:

```
{if "{westeros_content:count name='westeros_text'}"  > "1"}

```

HTH

---
Tags: conditionals, fluid-field
---


# Question
Title: SSL Certificate Breaking the Site Style Sheets - Looking for a fix
I've inherited an old version of an expression engine website using version 2.10.1. The site is not displaying on https:// and when I am testing the stylesheets are broken. I've been informed that the agency who designed the site a few years tried to fix it and was unable to ( which blew my mind.

So, can anyone advise me how to get the https://www.mysite.com version working please.

Thank you in advance... Naomi

# Answer
You'll need to access your templates fix this issue. Log in to your control panel, and visit:

`Design -> Templates -> Template Manager`

Most likely, you'll have a template group named "Embeds", "Includes", "Global", "Layouts", or something along those lines. In that template group you will likely have a template named "head" or "header". What we are looking for here is the template that outputs your website's `<head>` tag, which is where your stylesheets' `<link>` tags are going to be. I would edit those tags so they point at a protocol-relative URL instead of a hard coded one. So one example for you would be to convert this tag:

`<link href="http://www.mysite.com/assets/css/style.3.0.2.css" rel="stylesheet" type="text/css">`

to this:

`<link href="//www.mysite.com/assets/css/style.3.0.2.css" rel="stylesheet" type="text/css">`

This is actually an anti-pattern at this point, but it is probably the best way for you to move forward for now. You'll want to enforce SSL on your site at all times, but that is beyond this answer's scope, and using a protocol-relative URL will work now and after you enforce SSL. After you do enforce SSL, you should change those links to start with `https`, but they will still work with the protocol-relative URL so nothing should break.
> 2 votes

---
Tags: ssl, stylesheets
---


# Question
Title: How can I manually parse template code from PHP?
Is there a way to evaluate an ExpressionEngine template using PHP in a custom plugin?

I am using the Widgets plugin and want to create a custom widget type. I would like to define the widget output using an ExpressionEngine template.

So something like:

```
<?php
    echo evaluateExpressionEngineTemplate('{exp:navee:nav nav_title="main-nav"}');
?>

```

# Answer
> 14 votes
I'm not familiar with Widgets, so this may or may not be helpful.

If you are writing a plugin, generally you don't need to parse your own template code. Simply call:

```
$variables = array(array('name' => 'adrian'));
$this->EE->TMPL->parse_variables($template, $variables);

```

Which will parse any variables, loops, or conditionals inside your template. Third party plugins in the tagdata code will be left intact, and parsed automatically later on in the EE parse order.

However, if you really need to fully parse your own template code (for example, I have used this when sending emails), you need to set up your own instance of the EE template library, and duplicate some of the code which EE uses internally (this is pretty much the code we use in Store):

```
$email_body = '<!-- your template data here -->';
$tag_vars = array(array('name' => 'adrian')); // simple variables to parse directly

// back up existing TMPL class
$this->EE->load->library('template');
$OLD_TMPL = isset($this->EE->TMPL) ? $this->EE->TMPL : NULL;
$this->EE->TMPL = new EE_Template();

// parse simple variables
$email_body = $this->EE->template->parse_variables($email_body, $tag_vars);

// pretty lame that we need to manually load snippets
$result = $this->db->select('snippet_name, snippet_contents')
    ->where('site_id', $this->config->item('site_id'))
    ->or_where('site_id', 0)
    ->get('snippets')->result_array();

$snippets = array();
foreach ($result as $row) {
    $snippets[$row['snippet_name']] = $row['snippet_contents'];
}

// merge snippets into global variables
$this->EE->config->_global_vars = array_merge($this->EE->config->_global_vars, $snippets);

// parse email contents as complete template
$this->EE->TMPL->parse($email_body);
$email_body = $this->EE->TMPL->parse_globals($this->EE->TMPL->final_template);

// restore old TMPL class
$this->EE->TMPL = $OLD_TMPL;

return $email_body; // this is your parsed template

```

# Answer
> 4 votes
Adrian's approach is certainly correct, but I should also add that I abstracted everything into Channel Data so you can parse things MUCH easier. Take a look at my Channel Data library, it makes a ton of things a lot easier.

https://github.com/objectivehtml/Channel-Data

```
$string = '{exp:navee:nav nav_title="main-nav"}';

$this->EE->load->driver('channel_data');
$parsed_string = $this->EE->channel_data->tmpl->parse_string($string);

```

Some other methods in the tmpl parser in Channel Data are...

* parse
* parse\_array
* parse\_switch
* parse\_fieldtypes
* parse\_path\_variables
* parse\_single\_vars
* parse\_var\_pairs

All of my code is essentially the same as the first party, but it's been refactored so the methods are consistent and easier to work with.

Another solution is to use Stash https://github.com/croxton/Stash

```
{exp:stash:parse}
    {exp:navee:nav nav_title="main-nav"}
{/exp:stash:parse}

```

(Obviously this code would parse anyway, but you can late parse any variable with Stash, it's really powerful.)

# Answer
> 0 votes
I keep revisiting this answer and would like to add how I solved it in ExpressionEngine 3.

```
// load my own instance of TMPL as myTMPL
ee()->load->library("template", null, "myTMPL");

// get template as a string, and variables as name => value pairs
$template = ee()->myTMPL->fetch_template("mygroup", "mytemplate", false);
$variables = array("name" => "Mr. John Q. Public");

// render the template
$html = ee()->myTMPL->parse_variables($template, array($variables)); // merges variables
ee()->myTMPL->parse($html); // handles conditionals (doesn't seem to run plugins)
$html = ee()->myTMPL->parse_globals(ee()->myTMPL->final_template); // returns output

```

---
Tags: templates, plugin, widget
---


# Question
Title: Creating Custom Libraries In ExpressionEngine
In EE I am trying to create a php class that will query an API. When I look at the documentation for creating your own library classes (here: https://docs.expressionengine.com/latest/development/legacy/libraries/creating-libraries.html) I see that it says this about storing the library:

> Your library classes should be placed within your **system/ee/user/addons/addon\_name/libraries** directory, as this is where ExpressionEngine will look for them.

I don't see this directory anywhere in my project. Out of exhaustion I tried *creating* it and made a test class (just copied the example from the documentation except with an echo in the method) and loaded it, which resulted in an error... which I was expecting.

This is in *system/ee/user/addons/addon\_name/libraries/Someclass.php*

```
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Someclass {

    public function some_method()
    {
      echo 'test';
    }
}

```

With this in a template:

```
<?php
    ee()->load->library('someclass');
    ee()->someclass->some_method();
?>

```

This gives me a load error:

```
Error
Unable to load the requested class: someclass

```

At this point I'm not sure if I'm simply too tired and not understanding the documentation or if I'm in the Twilight Zone.

Can anyone clarify this for me? I would greatly appreciate it.

# Answer
Have you created all the necessary files for your add-on? I'm not sure EE will look for your library file in an empty add-on folder.

You need to make sure you have an `addon.setup.php` file at least, and possibly the basic framework for a module I believe for EE to try and load any libraries from your addon. You may need to install said module as well for it to be accessible. Try that first.

https://docs.expressionengine.com/latest/development/addon-setup-php-file.html

Also, what EE version are you running? And are you actually calling your addon `addon_name`? I highly recommend building a bare-bones module, adding your library to it, and installing it into your EE installation, that should work.

I definitely think you can't just have a random library folder in a non-complete non-installed add-on, you need to install a module for EE to look for a library folder and files in that add-on folder.

**Edit**

It seems you need a little help with setting up an add-on. I will try and make things clear and hopefully that will help.

Third party add-ons live in a folder of their own, inside of this folder:

`system/ee/user/addons/`

For this example, I am going to call my add-on `jrothafers_addon`. So to start, I will create this folder:

`system/ee/user/addons/jrothafers_addon`

In this folder, I will create my `addon.setup.php` file. The link above in my answer will help you fill out that file. Next, you will want to create either a plugin or module file. In this case, I will create a plugin file:

`system/ee/user/addons/jrothafers_addon/pi.jrothafers_addon.php`

Please note the name of that file, as well as the name of the folder being the same. In that file, I will have this code:

```
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Jrothafers_addon
{

    public $return_data = '';

    public function __construct()
    {
        $this->return_data = 'Hello World';
    }
}

```

Again, it is **very** important to note that the class name has a capital letter first, and the rest is exactly the same as the file name and folder name (`jrothafers_addon`). If you don't get this right, EE won't recognize your add-on.

After I have this setup, I can go to my ExpressionEngine control panel and visit `Developer -> Add-Ons`. If I scroll down, I will see my add-on listed under Third Party Add-ons. Once here, I can install my add-on.

So after all that happens, I'm hoping that you can access your library, which in my example, would live here:

`system/ee/user/addons/jrothafers_addon/libraries/Someclass.php`
> 4 votes

---
Tags: php, classes, custom-classes
---


title: Custom PHP throwing an error {!-ra:0000

text:
# Question
Title: Custom PHP throwing an error {!-ra:0000
We have a need to pull in data from an external source using PHP. I’ve run into this issue before where EE doesn’t like the PHP formatting i’m using, yet it seems to work elsewhere. For example, if i type the same code into phpfiddle it works fine. When i put it into EE i get the error {!– ra:000000007fef5f44000000007fd6e88d –} or something similar. Please see the code below. Any ideas of why this wouldn’t work? I do put the API key in and “URLGOESHERE” is where the actual API URL is.. i just removed for here.Thanks!

```
<?php

require “util/httpful.phar”;
$API_KEY = “”;
$startAt = 1;
$maxReturn = 20;
$url = “https://URLGOESHERE/sws/v1/offers/cruise?filter=supplier_id=26;searchable_destination_id=2&fields=offer_id,title&start;_at={$startAt}&max;_return={$maxReturn}”;
$response = Httpful\Request::get($url) ->addHeader(‘api_key’, $API_KEY) ->send();
$offers = json_decode($response, true);
$total = $response->body->meta->total;

$returnHtml = “<h1>Top Cruises</h1><ul>”; foreach( $offers[“offers”] as $offer ){
$returnHtml .= “<li><a href=”https://URLGOESHERE/index.cfm/cruise/offer/index?offerID={$offer">{$offer['offer_id']} - {$offer['title']}</li>”;

$returnHtml .= “</ul>”; $returnHtml .= “Showing results {$startAt} - {$maxReturn} of {$total}”;

echo $returnHtml;

?>

```

# Answer
> 0 votes
Does your php page works outside EE? I had that kind of problem with a phone script returning an error.

---
Tags: php, php-errors, phpstringfun
---


# Question
Title: Advanced Search Form Multi-select on Categories for one Channel
I am currently switching my site from the Simple Search Form to the Advanced Search Form. I would like to allow my users to search on the Categories for one channel. I used the example code provided in the documentation. I would really like to remove the "Channels" section on the search. I know I want to search one Channel (News). With the built Search module is there a way to do the multi-select on the category without the multi-select on the Channel?

I included a screenshot of what my search currently looks like and the code of the search template.

Thanks for your help!!!

```
{exp:search:advanced_form channel="news" search_in="entries" form_class="search-form" result_page="newsroom/results" results="12"}

<fieldset>
 <legend>{lang:search_by_keyword}</legend>
 <div class="search-keywords">
   <p>
     <label for="advancedKeywords">Keywords</label>
     <input type="text" name="keywords" id="advancedKeywords" value="">
   </p>
 </div>
 <div class="search-channels">
   <p>
     <label for="channel_id">{lang:channels}</label>
     <select id="channel_id" size="2" name="channel_id[]" onchange="changemenu(this.selectedIndex);">
         {channel_names}
     </select>
   </p>
 </div>
 <div class="search-categories">
   <p>
     <label for="categories_id">{lang:categories}</label>
         <select id="categories_id" name="cat_id[]" size="4"  multiple="multiple" style="width:154px;">
             <option value='all' selected="selected">{lang:any_category}</option>
     </select>
   </p>
 </div>
</fieldset>
<fieldset>
 <legend >Dates and sorting</legend>
 <div class="date">
   <select name="date">
     <option value="0" selected="selected">{lang:any_date}</option>
     <option value="7">{lang:this_week_and}</option>
     <option value="30">{lang:one_month_ago_and}</option>
     <option value="90">{lang:three_months_ago_and}</option>
     <option value="180">{lang:six_months_ago_and}</option>
     <option value="365">{lang:one_year_ago_and}</option>
   </select>
   <div class="date_order">
     <input type="radio" name="date_order" value="newer" id="newer" class="radio" checked="checked">
     <label for="newer">{lang:newer}</label>
     <input type="radio" name="date_order" value="older" id="older" class="radio">
     <label for="older">{lang:older}</label>
   </div>
 </div>
</fieldset>
<input type="submit" value="Search" class="button news-button">
{/exp:search:advanced_form}

```

# Answer
Ok, so this isn't really that hard. What you need to do is drop the auto generation of the select field for your form and just hard code the channel id you want to be passed to the search. This may need some tweaking to get working, but the idea is correct.

You will need to determine the channel id of your news channel to move forward. This example assumes the your news channel id is `123`. First, remove the generation of the select for channel from your code. So remove this line:

```
{lang:channels} {channel_names}

```

and in it's place, use this line:

```
<input type="hidden" id="channel_id" name="channel_id" value="123" />

```

Just replace `123` with whatever the actual id of your channel is. That should do it.
> 0 votes

---
Tags: search
---


# Question
Title: Is it possible to parse tags in an entry?
Is there any way to put EE tags in entries, by entering the tag in a textarea of a channel entry for example?

I know there was an old plugin that enabled this, but is there anything for EE5?

Thanks.

# Answer
> 0 votes
Yes - you can install the 'Allow-EEcode' add-on. But you should think carefully before doing so - there are all sorts of sensible warnings on the github page. **Almost** always you can find a way to refactor what you are doing to not require use of this add-on.

HTH

---
Tags: channel-entries, tags
---


# Question
Title: htaccess: remove trailing question mark and value after amp at the end of a url
i'd like to remove question mark and value at the end of a url ending with amp.

For example, i want the following url:

http://www.domain.com/category/page.html/amp?value=12

to be like this:

http://www.domain.com/category/page.html/amp

What is the right way to do it using htaccess? Thank you.

# Answer
> 0 votes
```
RewriteEngine On
RewriteCond %{QUERY_STRING}  .
RewriteRule (.*) /$1? [R=301,L]

```

You could test it e.g. here

---
Tags: htaccess
---


# Question
Title: Is it possible to get routes for entries within a custom module?
I can get all my entries, including entry url titles:

```
    $entries = ee('Model')->get('ChannelEntry')
         ->filter('status', 'IN', array('open'))
         ->order('title', 'ASC')
         ->all();

    foreach ($entries as $key => $entry) {
        $path = ee()->config->item("base_url")
        $path .= $entry->url_title;
    }

```

But is it possible to get the full url of all entries in a module? for example:

```
http://ee5-modules.localhost/blog/entry/the-one-where-we-shake-it-ff

```

# Answer
> 0 votes
Ehhh, yes and no. If you use the Channel URL explicitly for how you display entries in that channel, you can generate a list by pulling up that model as well.

The real problem here is that a channel entry is in no way tied down to a specific URL; I can have 100 different template groups and 100 different templates in each, and call an entry from any channel I want. There is no implicit URL for a channel entry; unless, as I said, you use the Channel URL setting on a channel to explicitly display entries in that channel, so this would be a self-imposed URL restriction.

Here is a rough example of how you might list all of the entries in one channel if this is the case:

```
$entries = ee('Model')->get('ChannelEntry')
                      ->filter('status', 'IN', array('open'))
                      ->filter('channel_id', 'IN', array('47'))
                      ->order('title', 'ASC')
                      ->all();

$channel = ee('Model')->get('Channel')
                      ->filter('channel_id', 'IN', array('47'))
                      ->all();

foreach ($entries as $key => $entry) {
    $path = $channel[0]->channel_url . '/';
    $path .= $entry->url_title;
    echo $path;
    echo "<br>";
}

```

So this is really rough. For example, I don't check if the Channel URL ends in a /, and just append one regardless, you'd want to test to see if one is there first before just appending. Also, in this example, I'm hard-coding a channel id of `47` (just a channel in an install I have somewhere to test real quick).

Now if you really had to do this for each channel and each entry, you could place a loop in a loop, but this would result in an `O(n^2)` timed algorithm, and be quite slow if you have a large number of channels/entries. Whatever you are trying to do this for, I wouldn't recommend it for any production applications that get used in public facing templates; this should be for a data export or something.

I'm not super familiar with the EE Model construct, and there may be some trickery you can pull to make this faster or more efficient, but this code example can at least do what I think you are looking for.

---
Tags: module
---


# Question
Title: EE 5.2: Parse error: unexpected '/' in … ee/legacy/libraries/Functions.php(627) : eval()'d code on line 27
I just have been noticed by Google Search Console that there are two pages with Soft 404 errors. So I cannot be sure when the error appeared first.

When calling the URL I get a blank page with the error:

> Parse error: syntax error, unexpected '/' in /var/www/…/system/ee/legacy/libraries/Functions.php(627) : eval()'d code on line 27

The strange thing is that only 2 (of about 1.500 pages with the same template) are concerned - the other ones work correct. As far as I can see in those pages there is nothing special (like php-code or using snippets).

When I close the entry I get a 404; when I reopen it the error appears again.

Already tried to clear caches (EE-caches as well as local browser-caches).

Anyone with any idea about this? Thanks in advance!

**Edit 17/03/2019**

As @jelle-dijkstra suggested I tried to recreate the entry. Something strange happens: 1) I delete the old entry. 2) I create a new one (just with blablabla-text). The new one is visible in the frontend without errors (URL like template/group/entryid or also template/group/urltitle/entryid) 3) I change the entry-id in the database (via phpmyadmin in the tables exp\_channel\_data and exp\_channel\_titles). If I set it to the "old" entry-id I get the error in the frontend; if I set it to any other entry-id (like 9999) the entry is shown correctly in the frontend.

Also strange is that in the last two days 3 new Soft-404-errors for new entries occurred.

Any idea?!?

# Answer
I could identify the problem: The plugin Rating from EEHarbor was the reason, because statistics where out of count. I had to recount the statistics via the CP, then everything was ok.

Problem in detail: Somehow the {overall\_sum}-variable was not calculated right from the plugin, it did not return a number but null. In my rating-embed-template I had some php-code with something like

```
$avg = ({overall_sum}/{overall_count});

```

As overall\_sum was null the operation returned nothing which explains the error "unexpected '/' ", as we had nothing/number … $avg = /17 instead of number/number $avg = 4/17
> 0 votes

# Answer
it might be something in those entries. maybe a strange symbol in the content, or a filename. you can also try to recreate those entries
> 0 votes

---
Tags: 404, ee5
---


title: CE Image Source Image is not readable

text:
# Question
Title: CE Image Source Image is not readable
I've got an EE5 site which was upgraded 3 months ago from EE2 and is now having trouble with new images being added.

I turned on debugging and am seeing this issue:

```
 CE Image debug: Source image is not readable or does not exist: '/uploads/general/Biden%20Holiday%20Card/biden-card-smaller.JPG'.

```

I've changed the upload folder permissions to 755 and then 777 and still no change with new image uploads.

FWIW the relevant template code is:

```
    {exp:ce_img:bulk add_dims="no" attributes="class='img-responsive'"}
        {blog_copy}
    {/exp:ce_img:bulk}

```

# Answer
Make sure you are setting your config variables correctly in your `index.php` or `config.php` file for CE Image. Here is an example I just pulled from a production EE4 environment (and an MSM site to boot, too, so from the `index.php` of the MSM site):

```
$assign_to_config['ce_image_document_root'] = pathinfo(__FILE__, PATHINFO_DIRNAME);
$assign_to_config['ce_image_cache_dir'] = '/ce_images/';
$assign_to_config['ce_image_remote_dir'] = '/ce_images/remote';

```
> 0 votes

---
Tags: error, image, ce-image
---


# Question
Title: EE API to get Entries outside of the EE environment
i want to build an APP which need access to channels of my EE instance. I found Open API (https://github.com/putyourlightson/open-api) but it is outdated (last change \> 5 yrs). Is there another way to get the entries (and other stuff maybe) or has someone experience with using Open API with EE?

Greetings

# Answer
Maybe you could use the excellent https://addons.reinos.nl/webservice
> 0 votes

# Answer
You can get Channel Entries by using latest feature of EE and i.e.`Model`. You need to write below code to get the entries.

```
$data = ee('Model')->get('ChannelEntry')
    ->filter('channel_id', 'enter_your_channel_id') //filter by channel_id
    ->all();

```

Here, I have included only `channel_id` as a `filter` parameter but you can add many more according to your requirement.
> 0 votes

---
Tags: api, open-api
---


# Question
Title: Exception Caught: 1615 Prepared statement needs to be re-prepared
Running ExpressionEngine 5.1.3, php 7.2 on Dreamhost shared server.

This error has brought our site down repeatedly for hours at a time over the last few days. We cannot access the site backend or any front end pages - just see the error. We made no recent configuration changes to the site. The complete error is like so:

```
Exception Caught
SQLSTATE[HY000]: General error: 1615 Prepared statement needs to be re-prepared: SELECT LOWER(module_name) AS module_name, module_version, has_cp_backend, module_id FROM (`exp_modules`)

mysqli_connection.php:117

```

Thanks for any suggestions!

# Answer
> 0 votes
You might be out of luck. Most likely, Dreamhost upgraded the MySQL version on that shared server and it isn't compatible with EE. Really, I would guess that when they upgraded, MySQL changed some default values for settings that are affecting you.

This may not be the case, but you should reach out to Dreamhost and see if they've deployed any upgrades recently. Unfortunately, if they have, it would seem very unlikely that they will mess with a shared server setting just for you and will just offer to move you to a better (and more expensive) hosting tier.

I do use Dreamhost from time to time, but I honestly wouldn't recommend a shared server of any type for a production instance of any application. I understand that things can be expensive, but I really wouldn't cheap out on hosting.

---
Tags: mysql
---


# Question
Title: Handling Forms With ExpressionEngine: the ACT ID
I have a form that is using the Amazon MWS API to pull in a list of reports to create a drop-down selection with options that contain the form id and name. I'm using the EE form helper to do this. Here's how the end of my method looks:

```
$xml = simplexml_load_string($response);
$options = array();
foreach ($xml->GetReportListResult->ReportInfo as $report) {
  $options[(string) $report->ReportId] = (string) str_replace('_', ' ', ucfirst(strtolower($report->ReportType)));
}
ee()->load->helper('form');
$form = form_open('ACT={action_id}');
$form .= form_label('Report types', 'report_types');
$form .= form_dropdown('report_types', $options);
$form .= cp_form_submit('Request Form', 'Processing your request');
return $form;

```

And in the template I'm doing this:

```
{exp:amazon_mws:get_report_list}

```

This is creating the form just fine. What I want this form to do is when someone selects a report type from the drop-down and hits `Request Form` it will run another function that will take the `ReportId` from the form and query the MWS API again to look for that report, save some stuff to the database (such as the report itself, the user, when it was created, etc) in order to display a list of reports.

The thing I'm struggling with is how actions are done in EE. There is not a lot of (if any?) documentation on this. The main thing I found was this article which is from 2012 and has broken reference links.

As far as I can tell, the way that something like this is done in EE is to use a `ACT ID`, as that article says.

> http://example.com/index.php?ACT=123
>
> Whenever ExpressionEngine encounters an ACTion URL, it attempts to run the code associated with the provided ACTion ID.
>
> **How it works**
>
> When an ACTion URL is loaded, ExpressionEngine looks in the `exp_actions` database table for an entry with the supplied ACTion ID. Each ACTion ID is associated with a class and method (i.e. the code to run).

Ok, great. That seems simple enough! I just need to know/create an ACTion ID for the method and *voilà*, it'll run when the form is processed. Only I don't know what the id is or what I would need to do to create it.

So I go to the documentation looking for `action_id` and I find this: `fetch_action_id($class, $method)`. So I create a test method in my class and use that function to see what I get: `<?php echo ee()->functions->fetch_action_id('Amazon_mws', 'action_id_test'); ?>`

what I get is this:

> {AID:Amazon\_mws:action\_id\_test}

Which is basically just the same thing I passed to the function.

You can see in the form I created above that I put `'ACT={action_id}'` in the `form_open` function. That's because I don't know how to do this and I assume you're supposed to put an action\_id there.

What I also tried to do was look at how other pre-made forms in EE are constructed, so I looked at the built in login form and found this:

*Ah-ha!* There's a hidden `ACT` input with a value of 14. I'm assuming this is the ACTion id for the EE login method. I also noticed when I use the `logout` link it goes to a url like this `http://www.example.com?ACT=15&csrf_token={token}`. So this is clearly using the ACTion id to run a logout method. Login is 14, logout is 15. This makes sense. I also noticed that when I use the form helper it automatically creates a hidden `csrf_token`, so I'm thinking I must do something like the above hidden inputs with my form in order to make it work.

I've scoured the documentation for some clarification on this issue but haven't had much luck. I'm either not good at looking up what I need (entirely possible, I'm not a super experienced dev and am only just learning EE) or the documentation isn't there. And I'm sure that this is something that EE devs are using constantly that's more or less taken for granted.

What I think I need to do is to enter the method I'm trying to use into the `exp_actions` table so EE knows that this is an ACTion method, but I'm not sure how to do this and I'm not seeing any documentation about it.

Any help would be greatly appreciated! Thanks.

# Answer
There is no magic method for this, as far as I know. It's pretty standard that in the `upd.your_addon.php` file, in the `install` function, you just add rows to your `exp_actions` table like so:

```
class Your_addon_upd {

    public $module_actions = array(
        'my_action_method_one',
        'my_action_method_two'
    );

    public function install()
    {

        foreach($this->module_actions as $method)
        {
            $data = array(
                'class'     => 'Your_addon',
                'method'    => $method
            );

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

    /* ... Rest of the methods for this file ... */
}

```

Just make sure your `uninstall` function also removes those rows from the `exp_actions` table.
> 2 votes

---
Tags: forms, act, action
---