# Question
Title: How can I sort entries by ascending integers?
I am trying to use a custom field `sort_order` to order entries by setting the Field Content type of a Text Input to Integer.

I'm using EE2.

Expected behavior:

1. Entry 1 with a `sort_order` of 10
2. Entry 2 with a `sort_order` of 20
3. Entry 3 with a `sort_order` of **110**

Actual behavior:

1. Entry 1 with a `sort_order` of 10
2. Entry 3 with a `sort_order` of **110**
3. Entry 2 with a `sort_order` of 20

Channel Field:

* Field Type: Text Input
* Field Label: Sort Order
* Short Name: sort\_order
* Field Options \> Field Content: Integer

Template:

```
{exp:channel:entries channel="work" orderby="sort_order" sort="asc"}

```

**Update**

I tried creating a plugin and setting `orderby` like this: `orderby="{exp:parse_int data={sort_order}}"`. Won't entry parameters always be converted to strings since they are wrapped in `"`?

**Update**

Decided to just ensure that my number strings are two digits long so they are in the correct alphabetical order e.g. `01 02 03... 99`.

# Answer
I think the Custom field `sort_order` may have value in `string` format. That's why it is not working.You need to convert it into `integer` format then try with it.

You can convert it by making small `pi.plugin_name.php` and wrirting code to convert `string` to `integer`. Then place your `{exp:plugin_name}` code in `orderby` parameter of Channel entries loop.

I hope above solution will work for you.
> 1 votes

# Answer
I cannot replicate your results.

Created a new channel "test" with a single field "counter" set to Text with field entry set to "integer".

Built template with this code:

```
<h1>Sorting Test</h1>
<h2>Sort with orderby="entry_id" sort="asc"</h2>
<ul>
{exp:channel:entries channel="test" orderby="entry_id" sort="asc"}
    <li>{title} - {counter}</li>
{/exp:channel:entries}
</ul>
<h2>Sort with orderby="counter" sort="asc"</h2>
<ul>
{exp:channel:entries channel="test" orderby="counter" sort="asc"}
    <li>{title} - {counter}</li>
{/exp:channel:entries}
</ul>

```

This gives the following output:

> # Sorting Test
>
> ## Sort with orderby="entry\_id" sort="asc"
>
> * entry 1 - 10
> * entry 2 - 200
> * entry 3 - 110
> * entry 4 - 20
> * entry 5 - 230
> * entry 6 - 220
> * entry 7 - 120
>
> ## Sort with orderby="counter" sort="asc"
>
> * entry 1 - 10
> * entry 4 - 20
> * entry 3 - 110
> * entry 7 - 120
> * entry 2 - 200
> * entry 6 - 220
> * entry 5 - 230

Works (i.e. tested) with EE2 and EE4 ... :)
> 1 votes

---
Tags: templates, custom-fields, fieldtype, orderby, sort
---


# Question
Title: Migrating ExpressionEngine 2.11 to version 4
I have an installation with ExpressionEngine v. 2.11 and need to move it to a new server so that will involve upgrading the installation to version 4

Where can I find some steps for migrating and any considerations I need to take into account before proceeding with this change?

Greetings, Leo

# Answer
You can find an outline of what is needed in the answer to a similar question asked a few months ago.

expression engine upgrade from 2 to 3 to 4

HTH.
> 1 votes

---
Tags: migration, server-migration, ee4, database-migrations, ee2.11
---


# Question
Title: EE3 - When image description is blank, use title field
I'm running into a roadblock here. Basically my client wants to use the "description" field of a file as the alt text, unless it isn't filled out, then he wants it to fall back to the page title. I am using this:

```
<li class="large-4 small-3 columns">
     {if right_image_1:description }
        {right_image_1}<img class="avatar w-alt" alt="{description}" src="{url}" />{/right_image_1}
    {if:else}
        <img class="avatar wo-alt" alt="{title}" src="{right_image_1}" />
    {/if}
</li>

```

But it keeps defaulting to the title field no matter what info i have in the description. Any idea what I'm doing wrong?

Thanks!

# Answer
> 6 votes
Try this:

```
<li class="large-4 small-3 columns">
    {right_image_1}
    {if description}
        <img class="avatar w-alt" alt="{description}" src="{url}" />
    {if:else}
        <img class="avatar wo-alt" alt="{title}" src="{url}" />
    {/if}
    {/right_image_1}
</li>

```

---
Tags: conditionals, file-manager, files
---


# Question
Title: Trouble searching Low events date with Low Search
I'm using the Low Events & Low Search code sample ( https://gotolow.com/addons/low-events/docs/search ) with the latest versions of EE, Low Search and Low events.

My Results tag filters my events by keyword correctly, how do I get it to filter by selected month-year?

`http://x.jp/index.php/show?keywords=test&low_events:date=upcoming`

`http://x.jp/index.php/show?keywords=test&low_events:date=2018-09`

`{exp:low_search:results
query="{segment_2}"
channel="show"
keywords:lang="en"
keywords:inflect="yes"
low_events:date""
}`

Sorry but I am quite new to this. Hope someone can help. Thanks!

# Answer
Remove the `low_events:date` parameter from the Results tag, as that will override any parameters given in the query.
> 2 votes

---
Tags: low-search, low-events
---


# Question
Title: Freeform 4.2.5 bcc notifications not sending
I have an old site running EE v2.11.3 and Freeform Pro v4.2.5. I know it needs updating but I can't at the moment for... reasons.

I have a freeform form that notifies admins on submission.

* admin\_notify email is sent OK
* admin\_cc\_notify emails are sent OK
* admin\_bcc\_notify emails are NOT sent

I've checked and double checked the form parameters.

I have email logs turned on in Freeform but no errors.

EE email is sent through sendgrid. In the activity feed of the sendgrid control panel I can see the admin and cc emails but nothing at all for bcc emails. No errors, nothing, it looks like they aren't being triggered by Freeform at all.

Parameters are like this (addresses changed).

```
admin_notify="aaa@test.com"
admin_cc_notify="bbb@test.com"
admin_bcc_notify="ccc@test.com"
admin_notification_template="find_local_members_to_admin"
notify_admin="yes"

```

Any ideas what else I can test or if anyone has come across this before.

# Answer
It is common for transactional email services to not support BCCs. Generally these services send to each address in the `to` field separately anyway, so CCing and BCCing aren't often necessary anyway.

You may want to verify with SendGrid that this actually works.
> 2 votes

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


title: EE2 - plugins page blank

text:
# Question
Title: EE2 - plugins page blank
I’m getting the “white screen of death” in the control panel, though only on the Add-ons-\>Plugins page.

I have turned on debugging mode, and the issue does not appear to have been caused by a PHP error. Can anyone think of any other reason why an individual control panel page would stop loading? I am getting no errors in the console, and the html is empty.

Many thanks in advance for any help, EE version 2.7.3

# Answer
EE has to look at all your plugin files to create the list of plugins. You have a rogue plugin that isn't formatted correctly, and is causing the issue.

Start by removing all of your plugins. Then add them back one by one until you find the culprit. You should do this on a staging or development server, of course.
> 2 votes

---
Tags: ee2, control-panel, plugin, white-screen-of-death
---


title: ?ACT= Member Creation

text:
# Question
Title: ?ACT= Member Creation
Is there is a specific ACT command in Expression Engine 3 I can run from a template to create members?

I can probably do this by saving directly to the database and while the password is not a problem since I can hash it I have no idea what Expression Engine is using for the salt and other hashes in the ee\_members tables since there is more than one. Is there a clean way to create members programatically?

# Answer
ExpressionEngine has most program friendly structure for this.

You can just write 2 db insert commands to save members programatically. Where 1 table would be `exp_members` and other one is `exp_member_data`.

For password, You can encrypt it with `md5` algorithm and leave salt and unique key fields blank. When user will login for the first time, password will be encrypted with salt and data will be save in table. (EE handles that.)

I would use this 2 queries to save members:

```
INSERT INTO `exp_members` (`group_id`, `username`, `screen_name`, `password`, `email`, `ip_address`, `join_date`) VALUES ('5', 'test_user', 'test user', MD5('test_user'), 'test_user@gmail.com', '192.168.1.1', '1534230407');

```

You will then need to fire a select query that will give you member\_id of data you just inserted. You can use username, email etc. to filter the result to get member\_id. Once you get member\_id, you can fire another query in `exp_member_data`.

```
INSERT INTO `exp_member_data` (`member_id`) VALUES ('$MY_MEMBER_ID');

```

**Note: Create member programatically live above will not validate data with EE validation library. If you want to have this functionality for backend it is fine. But, Use any member plugin for frontend member registration.**
> 1 votes

---
Tags: members, users, act, username
---


title: Matching more than one segment

text:
# Question
Title: Matching more than one segment
Matching one URL segments always works fine but is possible to match more than one?

For example this works:

```
{if segment_2 == "page"}nav-expanded nav-active{/if}

```

But this does not:

```
{if segment_2 == "page1" OR "page2"}nav-expanded nav-active{/if}

```

I tried all operators and conditionals possible and nothing works for me from the official docs here: **https://docs.expressionengine.com/latest/templates/conditionals.htm**

I need to match more than one page (not at the same time) but no operators I test like *equal*, *or*, *and* seems to work with *segments*. I'm trying to avoid having to create a whole new **{if segment\_2}** for every single sub-menu page

Maybe this is not possible?

# Answer
I would use this to check multiple pages:

```
{if "page1|page2" *= segment_2} active {/if}

```
> 3 votes

# Answer
You can try below code.

```
{if segment_2 == "page1" || segment_2 == "page2"} nav-expanded nav-active {/if}

```

I hope this will works for you.
> 1 votes

# Answer
Try

```
{if segment_2 == "page1" OR  segment_2 == "page2" }nav-expanded nav-active{/if}

```
> 0 votes

---
Tags: conditionals, segments, advanced-conditionals
---


# Question
Title: How do I install a custom javascript on all pages before the </body> tag?
I'm very new to ExpressionEngine and I couldn't find a similar question already posed. I have some javascript that I need to add to every single page. What's the best way to accomplish this?

OR

Is there instructions somewhere on how to install Google Tag Manager?

Thanks!

# Answer
I believe each EE site uses any template that shares same data. Like., Head, Header, Footer etc. You can select any of those templates and put your JS code inside it.

To find out, You can edit any template to see structure of the site. If You will find `{embed="..."}` tag that shares head, header etc. you can paste your code in that file that is embeding.

In my case, I create Snippets (In EE3/4 in called as template partials.) to store head, header, footer, footer JS. If your site uses those snippets, you can move your code there too.
> 1 votes

# Answer
Do you have access to edit the site templates? You'll need to do so.

Are your templates managed as files? If so, you'll want to open up your editor and make your changes directly on the file.

Depending on how your templates are organized it is likely you'll want to add your JavaScript snippet to either a "layout" template or to a template that functions as an "include" (embedded template). Just search for the `</body>` tag and you'll know which template it's in. If your templates are set up this way (with a globally embedded template that has the closing body tag, or a layout template), then adding the JavaScript snippet there should add it to your entire site.
> 0 votes

# Answer
You just need to create `embed` into `Comman` template group and include that created `embed` in any `template` where you want it.

Create `js-embed.html` in your `Comman` template group and paste your `javascript` code into it.

And, you just include that created embed by `{embed="comman_template_group/.js-embed"}` in the `template` you want.
> 0 votes

---
Tags: javascript, google
---


title: Invoice payment form with Authorize.net

text:
# Question
Title: Invoice payment form with Authorize.net
I have a potential website project that I may be working on that is currently built with Wordpress. The site uses Gravity Forms with the Authorize.net plugin to allow customers to pay invoices. They can use a single form to make a one-off payment or they can create an account and have their information saved for future payments. All credit card and personal information are stored with Authorize.net.

I will be rebuilding the site with ExpressionEngine 4 and need to recreate the functionality mentioned above. Without having to learn the Authorize.net API and building something from scratch, are there any existing plugins for EE that could make the above happen relatively painlessly.

Thanks for any help.

# Answer
> 0 votes
Both CartThrob and Expresso Store are specific store add-ons for EE4 and both have the ability to work with Authorize.net payments.

HTH

# Answer
> 0 votes
You can use CartThrob's built-in Vault functionality to do this: https://www.cartthrob.com/docs/tutorials/authorize\_later\_with\_vaults/index.html

---
Tags: expresso-store, cartthrob, payment-gateway, authorize.net
---


# Question
Title: 'If' conditional statement not working, returning PHP error
I am using EE v2.5 and following the documentation from https://docs.expressionengine.com/v2/templates/conditionals.html

I am trying to create an If Statement where if the Channel field labelled 'title' starts with the word 'Weld', it outputs something.

The title outputs on it's own as 'Weld Quip'

My code is:

```
{exp:channel:entries show_expired="yes" show_future_entries="yes" channel="service_agent_distributor" limit="1" url_title="weld-quip-group-pty-ltd"}
{if "{title}" ^= 'weld'} some text {/if}
{/exp:channel:entries}

```

I have also tried to create statement based on segments like this:

```
{if segment_2 ^= "weld"} Some text {/if}

```

I get a blank screen with one error: Parse error: syntax error, unexpected 'FALSE' (T\_STRING) in /public\_html/clients/projectname/area51/expressionengine/libraries/Functions.php(683) : eval()'d code on line 350

If I remove the 'if' statement it works again. Does anyone know why it wouldn't be working?

I should point out that this works, but I need the 'starts with' conditional to work.

```
{if segment_2 == "weld"}HELLO WORLD {/if}

```

# Answer
> 0 votes
You will not be able to use that operator.

https://docs.expressionengine.com/v2/about/changelog.html#version-2-9-0

This is when that operator was added to ExpressionEngine, nearly two years after the version you are using.

Upgrading is absolutely what you should do, but if you can't (many can't for a variety of reasons), your best bet is to use a plugin, or write a quick one yourself. Search here for EE2 add-ons and maybe one will work for you:

https://devot-ee.com

---
Tags: conditionals, ifelse
---


title: Channel entries vs embed files

text:
# Question
Title: Channel entries vs embed files
I’m having sort of a dilemma and since I never actually used channels in EE (yes, that is strange) except for a blog section I was curious what the real benefit is. I just don’t see it.

Let me make one example and maybe someone with more experience can answer this with a technical approach on why they are better.

I need to create documentation. So assume **/help** is a (template) which then embeds for example another intro template. So now you have **/help/intro** and of course you write your usual help documentation on intro or any other template files.

In the index of the group templates “**help**” I can just create if segments calls, for example:

```
{if segment_3 == 'to-super-product'}embed="help/some-other-template "}{/if}

```

And now we have something nice like:

*example.com/help/intro/to-super-product*

Now, of course the proper way is to use channel entries for each article so instead of using a segment\_3 you create a channel entry for each chapter.

The problem with that approach is that now you are limited to the constraints on the channel entries boxes. Unless you use a plugin from Ellis Lab you cannot use EE variables inside a content anymore and they advise against it for security.

For example with the templates approach I could have a variable called `{version_number}` and use this on all my documentation, I change that variable and its changed everywhere. I can edit and design everything as I want with HTML and the help articles are completely dynamic.

But if you go the channel entry route, you are constrained to making the content static. You cannot use the `{version_number}` anymore, or if you want to change colors, fonts or other things help wide you cannot do this unless you go to the Expression Engine control panel and edit each channel entry individually.

I’m surprised why everyone is using channels when it seems inferior. The only advantage I see here is if you need to let users that are not coders/designers to edit the content and you don’t want them messing any code. But to achieve the same visual effects in a page, you would have to create a lot of different channel entries which they need to edit one by one.

What I’m approaching wrong here? Editing HTML files seems like cleaner and I can make them dynamic vs having static channel entries. When I mean static, I mean the content inside. For example changing fonts, notes, version numbers, product names...

**UPDATED:**

I don’t use it to create static HTML and this is exactly what channels do. When you get content from a channel, that content of HTML block is constrained by only the HTML that someone saved from the control panel.

Let me try to clarify this. I don’t let anyone else edit the content now. I create the content. Maybe that is why I see little use with channels today. I can completely understand how useful they are to separate content from code if you are allowing other people to edit or add content text or images to pages.

Let me make a simple example. Do you see the yellow box on your reply that you quoted? Lets assume this is pulled from a channel entry. That text is all you get in terms of formatting. If you want to change letters to BB or change something dynamically with CSS you can’t.

But if the same text is directly saved in a template, and I have the correct EE variables around the content or code I want, I can modify it on the fly, site wide. This is exactly why EE is so great. You can make sites dynamic. But channels are static content. Yes, you can limit how may entries, sort them by date, category, and many other things but the content you get from a channel entry is fixed and limited by the fields you allowed someone to save from the control panel.

I'm not new to EE. I used it since version 2 but just never had to use channels because I feel constrained by them vs just editing templates directly which seems cleaner and faster. All the examples and tutorials are the same. They show how to create a news section, a blog, or other simple blocks of texts entries you would add to a database. Nobody seems to create a very advanced use or case scenario example. I can also see channels being useful in that regards, if you need to enter a lot of items which are similar and then need to classify or sort them. In that case, a channel entry is a database entry so its very useful for data organization/classification. But I'm referring to unique web page content that is completely different but you still need to change it automatically or dynamically on a site.

# Answer
> 3 votes
I'm really confused by your question, but I'm going to make an attempt at clarifying some base concepts that I think you are wrongly assuming about a commercial grade CMS (content management system) like ExpressionEngine, and CMS's in general (possibly, not trying to say you don't know what you are doing).

First of all, this is a content management system. It is not a static site generator or a system for implementing flat html content. It is a CMS. The base idea behind a CMS is that you have a functional system that creates a connection between data that lives in a database and how you express and control the output of that data through templating. CMS's also add functionality like user registration and dynamic routing and so on. EE does this.

> For example with the templates approach I could have a variable called {version\_number} and use this on all my documentation, I change that variable and its changed everywhere. I can edit and design everything as I want with HTML and the help articles are completely dynamic.
>
> But if you go the channel entry route, you are constrained to making the content static. You cannot use the {version\_number} anymore, or if you want to change colors, fonts or other things help wide you cannot do this unless you go to the Expression Engine control panel and edit each channel entry individually.

OK... This is where I get really confused.

The system of data control in Channels and how you template are not at all fractured. They work together great. The point of a system like this is to allow developers to create a diverse CMS that lets content editors do their job without having to know HTML or CSS or JS or EE templating code.

For example, you could control versioning of your documentation through EE Categories and Channels. The EE documentation does it without issue. And it does it with:

-Different styles from EE2 to EE3/EE4 docs
-Different architecture throughout
-Possibly different search appliances depending on the doc version you are looking at

I keep saying I'm confused because EE is a fine system for architecting and implementing documentation. I've done it and seen other (way more talented) developers do it as well.

I think you need to re-tour the basic docs on this system if you want to keep using it. If what you want is a flat site with no content control, this isn't the right choice because you are way under-using its capabilities.

Please edit your question with a little more info on what your site is trying to do. We want to help, but from your question I can only assume you don't know what you need or you don't know how to utilize EE properly.

---
Tags: channel-entries, templates, channel, template-partials, template-manager
---


title: Server error caused by file upload

text:
# Question
Title: Server error caused by file upload
I've got a client who has been trying to upload huge audio files via FTP and then syncing the files in the file manager. The client has found accessing the file manager results in a server 500 error. The web hosts said the server logs reported that 'Script timed out before returning headers: admin.php'. And so the 'software'(ie ExpressionEngine) was the cause.

I'm not convinced, but wondered if there is any setting in EE that can be altered to prevent the timeout.

On a separate issue, the server is located in California, and the client is in the UK. Would that be a cause?

# Answer
Consider using Assets from Pixel-Tonic? What file-size are we talking about? Maybe your hosting provider isn't providing enough performance?
> 0 votes

---
Tags: file-uploads, file-manager, server, hosting, error-500
---


# Question
Title: MSM Upgrade from EE 2x to EE 3.5.16, now can only see primary site
I upgraded from EE 2x, to EE 3.5.16. I can see my primary site fine, but the other sites (both index.php and admin.php) say:

> Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php

So I have checked all the usual - open\_basedir looks ok (has not changed):

```
{WEBSPACEROOT}{/}{:}{TMP}{/}:/var/www/vhosts/site1.com/httpdocs/:/var/www/vhosts/site2.com/httpdocs/

```

Folder permissions are 755 on site1.

Just to check the system\_path, in index.php for domain2, I have added:

```
echo SYSPATH.'ee/EllisLab/ExpressionEngine/Boot/boot.php';

```

And this shows the correct path when I access index.php i.e.

> /var/www/vhosts/domain1.com/httpdocs/softwater/ee/EllisLab/ExpressionEngine/Boot/boot.php

I can access the domain2 control panel by first logging into the domain1 control panel.

I'm truly stumped. Everything was working fine with EE2 - what could have gone wrong?

# Answer
The solution was to use the following:

```
setfacl -R -m u:site2-user:rwX /var/www/vhosts/site1.com/

```
> 1 votes

---
Tags: multi-site-manager
---


title: embed:title== two words?

text:
# Question
Title: embed:title== two words?
A client asked me to took over his website recently to update on his behalf so the site was produced by a previous developer so I am quite new to Expression Engine.

Only pages with single word can show the active menu colour (background + border) when we are on the current page but not other pages with two words.

Heres the code:

```
<a href="{site_url}team" {if embed:title=='Our Team'}class="active"{/if}>Our Team</a>
<a href="{path='services/taxation'}" {if embed:title=='Taxation'}class="active"{/if}>Taxation</a>

```

I found that one word would work fine but not two words. I tried:

```
Our Team
Our%20Team
Our-Team
Our_Team

```

Any suggestion? Thanks heap!

# Answer
> 1 votes
It should work. Did you tried:

```
{if "{embed:title}" == "Our Team"} class="active" {/if}

```

# Answer
> 1 votes
Can you use the url\_title instead ?

---
Tags: ee2
---


# Question
Title: Does anyone know how to create a staging for Expression Engine version 2?
I am wondering where can I find some steps to create a staging for EE2 ?

# Answer
> 5 votes
If you know how to create a production or development server for EE2, you can create a staging server... if you don't know how to create a development or production server then go find that out first.

The challenge with database driven CMS's however is not the servers, it is the database that drives the CMS. Before you can push changes that include any changes to the database (i.e. in EE2, that's most things except perhaps javascript or CSS changes) you need to be sure that any changes in the database on the production server are replicated back to the development server... (otherwise when you ship the development server database to the production server, you may overwrite any changes that have happened on the production server while you were working on the development copy...)

There is no elegant fix for this - how you solve it very much depends on what you use the CMS for and what sort of changes you plan on making.

This is not an EE issue specifically - you'd have the exact same issue with any database driven CMS.

If you give some more info on what kind of environment you want the staging server for, maybe there is scope for a more complete answer, but for the generic concept this is it.

HTH

# Answer
> 1 votes
You might want to consider this Bootstrap file from Ben Parizek (originally from Leevi Graham). It allows for Local, Development (Staging) and Production (Live) environments. You can set different environment variables and database connections for each. Works well if you're using (and you should be) a code versioning system, and the some kind of deployment tool.

---
Tags: ee2, matrix, staging-server, admin.php
---


title: Simple Registration (EE3) 1.6.2

text:
# Question
Title: Simple Registration (EE3) 1.6.2
The latest version in Devot: ee is 1.6.3 which is compilable with EE4.

If you buy this latest version, can you access version 1.6.2, which is compatible with EE3?

How can it be requested?

Thank you

# Answer
> 1 votes
For EE add-ons, the market and culture generally always allows you access to previous versions. For top-level add-on teams, when you buy a current license for an add-on, you actually get EE2, EE3, and EE4 versions of the files in a single download.

But, the answer is to reach out to the add-on author if you can and find out.

---
Tags: simple-registration
---


title: What should be in a robots.txt?

text:
# Question
Title: What should be in a robots.txt?
I've inherited an ee site, having never really worked with one before, and the robots.txt has multiple things that I would normally assume shouldn't be in there, such as:

* /assets/
* /images/
* /themes/
* and some specific files.

Given my understanding these items will now never be crawled by the search engines.

Also putting specific files in there just easily reveals them to the wider world, it's not really helping security is it? In fact the opposite.

Anyone with any advice would be appreciated, if there are folders that should be in there for ee then that's fine.

# Answer
> 1 votes
Well, There is no specific files or folders to put compulsory in robots.txt for EE. This is a file where people usually put things to allow or disallow search engine to crawl given folders or URLs. You can also pass sitemap in robots.txt file.

Specific answer to your question will be, It's okay to remove those folders from robots.txt if you want to crawl them. Nothing to do with security.

---
Tags: ee3
---


title: PHP fileinfo and MimeType.php

text:
# Question
Title: PHP fileinfo and MimeType.php
I get this error after upgrading to EE 2.10.1

> Fatal error: Call to undefined function EllisLab\ExpressionEngine\Library\Mime\finfo\_open() in /home/foo/bar/EllisLab/ExpressionEngine/Library/Mime/MimeType.php on line 117

I can't upload files through the CP or synchronise in file manager.

I've tried adding fileinfo.so to extension in php.ini as suggsted here https://stackoverflow.com/questions/3579072/php-fileinfo-is-undefined-function but it didn't do anything, just got the same error message.

# Answer
> 4 votes
EllisLab addresses this issue on a blog post. Part of it:

> If you encounter problems with uploading files check the following:
>
> 1. Login to your CP and go to Tools, then Utilities, then PHP Info. If you see --disable-fileinfo on that page (I recommend using your browser’s search function) then you will need to contact your host and have them provide a version of PHP with fileinfo not disabled (i.e. enabled).
> 2. Check your system/expressionengine/config/mimes.php file. If it does not contain $whitelist = array around line 31 you will need to upload a fresh copy.

There's more useful info there.

# Answer
> 0 votes
I solved this installing php7.0-gd.

```
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

```

Next, install the desired version:

```
sudo apt-get install php7.0-gd
# or
sudo apt-get install php7.1-gd
# or
sudo apt-get install php7.2-gd

```

---
Tags: file-uploads, files
---


# Question
Title: Error when trying to access a channel from the backend
Good evening!

I was wondering if anyone has seen this issue before. Whenever I try and access the backend details of a channel, I'm getting this php error:

```
Error: Unable to load requested field type file: ft.calendar.php.
Confirm the fieldtype file is located in the /system/user/addons/ directory

```

Has anyone ever seen this one before?

Thanks for anybody's thoughts. :-)

# Answer
You are missing a file from an add-on, most likely Solspace Calendar. You will need to verify the installation of that add-on is complete, and correct for your version of EE (which is either 3 or 4). The missing file would be `/system/user/addons/calendar/ft.calendar.php`.

The other option is to remove the add-on, but this can be dicey if you already have an incomplete installation. To manually remove it, you'll need to go through several database tables (at least `exp_actions`, `exp_extensions`, possibly `exp_plugins`, `exp_fieldtypes`, and maybe even others) and remove reference to it. If you have the calendar field as an actual field in any channel, this gets even more complex to remove properly.

So go with the first option of verifying the installation and proceeding from there.
> 3 votes

---
Tags: add-on, fieldtype
---


title: Responsive Images EE4 best solution?

text:
# Question
Title: Responsive Images EE4 best solution?
I'm looking to do responsive images with EE4, where you serve smaller versions of an image for mobile devices. Can anybody recommend a good method? I've noticed many references to CE Image, but it appears that's only up to EE3.

# Answer
CE Image is an excellent choice. Although Aaron doesn't specifically support EE4 with this add-on, I have had a client directly contact him and be told that the latest EE3 version should work with EE4. And for myself, it does. I currently have two EE4 sites that I did the upgrade work on that use CE Image with EE4 and we haven't noticed any issues or loss of functionality.

The add-on is a plugin, and plugins are the simplest add-on types. They essentially just expose PHP methods to a template, and usually don't interact with EEs internal APIs at all.

Reach out to Causing Effect about it, but it should work for EE4 out of the box.

But buyer beware; and it would be best if you are a developer yourself so you if you do run into minor bugs, you can fix them yourself.
> 5 votes

# Answer
`CE Image` is the all time great solution for Resizing/Responsive images for `EE`. If you've `CE Image` version `3.0.1` then no need to worry about it. It will definitely work for you. There is no special version for `EE4`, version`(3.0.1)` is fully compatible with `EE4`. You can rock with it.
> 2 votes

# Answer
Bought CE Image (for EE3) and it works perfectly with EE4, following the tutorial at https://www.aaron-gustafson.com/notebook/adaptive-images-in-expressionengine-with-ce-image/. To quote the important part of that page, use this code, replacing {embed:image} with your image URL:

```
<img class="page__image-header__photo" alt=""
{exp:ce_img:pair
src="{embed:image}"
filename_suffix="_small"
width="480"
height="320"
crop="yes"
interlace="yes"
cache_dir="/"
}
src="{made}"
srcset="{made} 480w,
{/exp:ce_img:pair}
{exp:ce_img:pair
src="{embed:image}"
filename_suffix="_medium"
width="800"
height="600"
crop="yes"
interlace="yes"
cache_dir="/"
}
{made} 800w,
{/exp:ce_img:pair}
{exp:ce_img:pair
src="{embed:image}"
filename_suffix="_full"
width="940"
allow_scale_larger="yes"
crop="yes"
interlace="yes"
cache_dir="/"
}
{made} 940w"
{/exp:ce_img:pair}
>

```

To produce this output:

```
<img class="page__image-header__photo" alt=""
src="about_480_320_int_c1_small.jpg"
srcset="about_480_320_int_c1_small.jpg 480w,
about_800_350_int_c1_medium.jpg 800w,
about_940_343_int_s_c1_full.jpg 940w">

```

That produces a working demo. Then naturally you'll modify for your needs.
> 2 votes

# Answer
You can also use Channel Images from Ee harbor I think (before it was Devdemon )
> 1 votes

---
Tags: ee4, responsive-images
---


# Question
Title: What's the best way to search for specific terms in files?
I have a situation where the client will be uploading a ton of pdf files, and then on the front-end we need a tool to search for key-terms within these files. Sometimes that key-term is in the file name (could possibly break apart with php to get the terms?) and sometimes the key-term is just in the file itself.

php to break apart the terms:

```
                <?php
                    // break apart file name, grab first word
                    $str = '{title}';
                    $arr1 = preg_split("/[_,\- ]+/", $str);
                ?>
                <?php echo $arr1[0]."\n"; ?>

```

Which takes a file name like: *FFOBBULUSE000002\_Harlequin GDP 3.5g TruFlower Cup.pdf* and outputs the first term like: *FFOBBULUSE000002*

I've looked into Channel Files, and of course native EE search and File Entries, but none are really giving me what I need. Native search doesn't seem to be able to search native files, nor Channel Files?

Plus, there are thousands of these files, so I don't really want to load them all into a template and then filter. Hoping for a less resource-heavy way of doing this.

**Example:**

Uploaded file: *FFOBULN2F000004\_9lb 600mg Vape Cartridge.pdf*

Someone may search for the term: *FFOBULN2F000004* \- that term needs to be able to pull up this file in the results, and also shouldn't be case sensitive.

Any ideas?

***UPDATE:***

I'm getting really close via using Stash. Here's what I have so far:

```
{exp:stash:set_list parse_tags="yes" name="my_entries"}

    {exp:file:entries directory_id="19" orderby="date" sort="desc" limit="3000" disable="relationships|categories|category_fields|member_data|pagination"}

        {!--<!-- [STORE PHP VALUE IN EE VARIABLE TO USE LATER] -->--}
        <?php
            // break apart file name, grab first word
            $str = '{title}';
            $arr1 = preg_split("/[_,\- ]+/", $str);
            //echo $arr1[0]."\n";
        ?>
        {stash:batch_value}<?php echo $arr1[0]."\n"; ?>{/stash:batch_value}

        {stash:batch_number}{exp:stringer:striptags words="1"}{title}{/exp:stringer:striptags}{/stash:batch_number}

        {stash:entry_title}{title}{/stash:entry_title}
        {stash:count}{count}{/stash:count}
        {stash:url}{file_url}{/stash:url}

    {/exp:file:entries}

{/exp:stash:set_list}

{exp:stash:get_list name="my_entries" match="#(?i){freebie_3}#" against="batch_number"}

    <div class="item {batch_number} field-id-{count}">
        <p><span>{entry_title}</span> // {batch_value} - <a href="{url}" title="Download {entry_title}" download>Download</a></p>
    </div>

        {if no_results}
            {exp:stash:set name="my_message"}No results{/exp:stash:set}
        {/if}

{/exp:stash:get_list}

```

This is working almost perfectly.

But now, when I have php parse set to input, I get the full file name (doesn't break it apart and give me the first word). When I have php parse set to output, I get this error:

> NOTICE UNDEFINED VARIABLE: ARR1 ee/legacy/libraries/Functions.php(682) : eval()'d code, line 46
> Severity: E\_NOTICE

I've tried using stringer to get the first word, but it doesn't break on underscores, and I need that :/

# Answer
> 1 votes
I got some feedback from the developer of Stash (Thanks again, Mark!) on this via Twitter, and he advised not to do it this way.

So I went back to the drawing board. I ended up having our programmer help me out and write some custom php to perform a search in the file directory, and return the results in my template, rather than use any EE tags.

Basically, the php converts all of the file names to lower-case. Then searches the filenames to match against the key-term entered. Removes the server path from the file so we have a clean URL and display file name. Then writes the results to the template.

---
Tags: stash, search, php, files, channel-files
---


# Question
Title: Settings in Admin get dropped, will save temporarily, hours later are reset/gone
I have a situation on my development site, where all of a sudden lately, some things I save in the admin, aren't "sticking" around.

Some of the settings that won't stay:

**Template routes:** I will set up some routes, they'll work for a while, hours... and then I'll start getting 404's when trying to access these routes. I go back into the admin and my routes are suddenly gone.

**Structure settings in entries:** I'll assign a template to an entry, again this will work fine for a while, hours etc, and then suddenly I'll start getting 404's for these entries. I go back to the entry and the template is no longer assigned to the entry.

**Template settings:** I'll set php settings to "Yes" and parsing to "input" - php will be working fine in my template, and then a few hours later, BOOM the settings are back to the default.

I have verified with our sysadmin that the DB looks in good shape, and we're not seeing any php or other errors. I have debugging on etc.

# Answer
> 1 votes
This actually turned out to be an issue with the plugin "Template Sync" - EE support helped me figure it out (thanks Robin!).

Narrowed it down to just a templates issue, and found "Template Sync" was deleting my templates from the DB. And was fine to uninstall since it was no longer needed after EE 3.

Uninstalled the plugin, and everything is working fine now!

---
Tags: templates, control-panel, database, admin, settings
---


# Question
Title: FreeForm Pro, Dynamic Recipients field - where is this data stored?
I have a long dynamic recipients field defined for one form, and a client wants that same field in another form. Instead of re-typing it all manually I'd like to edit a database somewhere, but I can't find where this field is located. Can anyone point me to the right place? Using EE 2.7, FreeForm Pro 4.2.5

# Answer
Found it. You reference exp\_freeform\_forms for your form and identify the composer\_id field. Then you reference exp\_freeform\_composer\_layouts matching composer\_id and get it from the composer\_data field.
> 2 votes

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


title: What's EE4's best forms solution?

text:
# Question
Title: What's EE4's best forms solution?
I'm trying to teach myself the best tech related to EE4. Now I'm on forms. Before going straight to FreeForm Pro, I'd like to get any opinions on form solutions. Currently looking into Channel Form and deciding whether to even mess with it (already bought FreeForm Pro).

# Answer
> 2 votes
In the world of **EE4** Freeform Pro will be perfect choice for creating the forms. And if you want to play with **channels** then Channel Form comes in the picture. All things depends on your requirement, what you actually need. Both are perfect in their scenarios.

# Answer
> 1 votes
Freeform Pro is a solid choice, and has good support. Depends what you are after - you can do alot with the built in Channel Form function.

Also you would do well to be familiar with the marvellous Snaptcha \- **really** effective spam avoidance.

---
Tags: forms, ee4
---


# Question
Title: Any recommendations for a multilingual feature/addon with RTL and LTR languages on EE4?
Is there a native functionality for additional languages in EE4 or should we go for an addon for a site with LTR and RTL languages?

Please share your experiences.

# Answer
> 1 votes
okay it seems you are into this too. if you want to spend 200$ use https://boldminded.com/add-ons/publisher-2

if not; here is the tips for an easy way to do it. lets say that you have two languages English - en Arabic - ar

first duplicate your fields in your channels and make sure that you suffix the field name with the short-code of your language Like:

{title\_ar} {body\_en} {body\_ar}

if you need categories add a custom field for your categories lets say the English is your default language : {category\_name\_ar}

if you have variable; you can use the suffix too, like: {home\_en} : home {home\_ar} : الرئيسية

=== in you blog template === use the template routs and make sure the segment\_1 as the language short-code like: template group Blog/index

```
/{lang:regex[(en|ar)]}/blog/{section:category}/{page:pagination}

```

now the url of the "Blog" will be like: https://localhost/ar/blog/ https://localhost/en/blog/

in your template the code will be like this:

```
   <ul>
      <li>{home_{segment:lang}}</li>
    {!-- this will translate the variable upon requested URL --}
    </ul>

 {exp:channel:categories}
        <a href="{path='{segment:lang}/blog/'}">
    {if segment_1 == "ar"}
{category_name_ar}
{if:else}
{category_name}
{/if}
    </a>
    {/exp:channel:categories}

    {exp:channel:entries channel="blog" }
<h2>
  {if segment_1 == "ar"}
    {title_ar}
    {if:else}
    {title}
    {/if}
</h2>

<p>{body_{segment:lang}}</p>
 {/exp:channel:entries}

```

there is many ways to do so this is the easiest way to do it natively

hope you find this useful

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


# Question
Title: Displaying the number of entries in a category
Is there a way to select channel, list out the categories assigned to that channel and then the number of entries in each category?

What I want is something link the below:

Category 1 - 100 entries Category 2 - 70 entries etc...

I've tried this, but dosn't get me what I want:

```
{exp:channel:categories channel="news"}
                  <li>
                    <a href="#">{category_name} ({exp:channel:entries category="{category_id}" dynamic="no"}{absolute_results}{/exp:channel:entries})</a>
                  </li>
                  {/exp:channel:categories}

```

# Answer
Yes, this is possible. You can do this by making simple template and embed.

Create one template `template_name.html` in your template group and insert below code.

```
{exp:channel:categories channel="channel_name" disable="category_fields"}
    *******************************************************
    <br>

    Category Name : {category_name}
    <br>

    {!-- including the embed which have channel entry code --}
    {embed="template_group_name/.embed_name" cat_id="{category_id}"}

    *******************************************************
    <br>
{/exp:channel:categories}

```

Now create one embed `.embed_name.html` into that template group. And insert below code.

```
{exp:channel:entries channel="channel_name"
disable="category_fields|member_data|pagination|trackbacks|relationships" dynamic="no"
category="{embed:cat_id}"}

    {if count == 1}
    Total Entries = {total_results}<br>
    {/if}

{/exp:channel:entries}

```

I hope this will definitely works for you.
> 4 votes

# Answer
this feature is not supported Natively you can use the query module for this or third party

http://gwcode.com/add-ons/gwcode-categories/examples/example4

This add-on has been ported to EE3 / EE4 compatibility - though labelled as a beta the updated version works well. Find the updated version discussed in this thread, and the downloadable version here.
> 1 votes

---
Tags: categories, channel
---


# Question
Title: Automatically creating an alphanumeric number for each new entry
I have setup a JSON feed to allow single sign-on to another system. Currently the `entry_id` and email are used as part of the URL string to access the 3rd party system, but this number could be guessed. I would like to provide some security by outputting an alphanumeric string as one of the fields, and using this in the URL instead.

Is it possible to have such a string created automatically in a new field when an entry is created? Are there other options for implementing this type of security?

So currently the single sign-on URL looks something like:

```
http://example.com/SingleSignOn/Microsite?externalId=123_someemail@foo.com

```

Where `externalId` is a combination of the entry\_id and email address of the user.

I want it to be more like:

```
http://example.com/SingleSignOn/Microsite?externalId=983FFC60-90DB-4527-81FD-831F4C4AD5B3

```

I'm not sure where to start - any advice or suggestions welcome.

# Answer
> 3 votes
If you are using EE4 then you could use the built-in encrypt / decrypt variable modifiers. So your template entry could end up with something like this perhaps:

```
{path='SingleSignon/Microsite'}?externalId={entry_id:encrypt}{email:encrypt}

```

HTH

---
Tags: security, json
---


title: Javascript for scrolling calendar

text:
# Question
Title: Javascript for scrolling calendar
I'm trying to implement this: https://www.viget.com/articles/building-an-expressionengine-mini-calendar-scroller/

However comments are closed and the contact link goes to an agency. Help! I'm clearly not adding the Javascript snippet correctly, everything else seems to work. What am I doing wrong? Here is the test page:

https://www.sea.edu/sea\_currents/calendar-test

Calendar is in the lower left, the arrow should slide the old month out of the way and pull in the new one, rather than directing to a new page.

Thanks!

# Answer
> 1 votes
You need to make some changes to the jQuery. See below:

```
$(document).ready(function() {
    $(document).on('click','.nav-calendar a',function(e){
        e.preventDefault();
        var $this = $(this),
            action = $this.parent().attr('class'),
            $wrapper = $this.closest('div.scroller-wrapper'),
            $cal = $this.closest('div.content');

        $.get($this.attr('href'), function(data) {
            var $d = $(data),
                delta = (action === 'prev') ? '-100' : '100';

            $d.css({
                'left' : delta + '%',
                'position' : 'absolute'
            }).appendTo($wrapper);

            var newHeight = $d.height();

            $cal.html($d).animate({
                'left' : '-='+delta+'%'
            }, 250);

            $wrapper.animate({
                'height' : newHeight
            }, 350);
        });
    });
});

```

From the above code `$.get()` is the Ajax request which loads the HTML content from the URL provided in next/previous arrow links.

Also, you need to create another template which will only have the calendar code which will be used by the Ajax request URL.

---
Tags: javascript
---


# Question
Title: Changed our site IP address, now can't login to EE
We moved our site to a new server, have a new IP address. Now, when I go to www.nameofthesite.com/admin.php and log in, I get a blank screen.

Do I need to change the IP somewhere in the EE config files?

# Answer
You are most likely getting a 500 error if you are getting a blank screen while trying to log in. This will have nothing to do with your IP address, this is a fatal PHP error occurring.

In order to determine what is going wrong, you need to turn error reporting on.

https://docs.expressionengine.com/v3/general/system\_configuration\_overrides.html#debug

Set this value in your config.php file, which either lives in

`EE2: {web_root}/system/expressionengine/config/config.php`

or

`EE3 & EE4: {web_root}/system/user/config/config.php`

Note that when you set this value, you must set it to `2` to see what error is showing after you attempt to log in. Also note that if the front end of your website has suppressed warnings, they **will** start showing up while the debug override is set, likely breaking some pages on the front end of your site.

If you just moved from one server to another, a common error you will see is that you are missing some vital PHP module, such as `php-mbyte`, for EE. The solution is to install the missing PHP module and restart Apache. Another common error is that you will be missing some files from when you transferred from one server to another; EE fails if it is missing any third-party files usually.
> 2 votes

# Answer
Thank you so much for the answer. I appreciate it. I was able to work with Ellis Labs and get it working again. There was an error in one of the config files.
> 1 votes

---
Tags: admin.php
---


# Question
Title: Channel Videos not saving new videos (EE2 site upgraded to EE4)
**Background:**

EE2 site with channel videos among other plugins. Following a successful upgrade to EE4.3.1 the site is functioning correctly, and old videos are working.

The issues begin when trying to add new videos, they can be found successfully, or added directly from a url, but upon saving, they disappear. The video also doesn't seem to find a date, it just returns invalid date.

This issue is similar to this question: Channel Videos - Removing Video When Saving

The plugin code that we have now is downloaded from the Dev Demon site, before the migration to EE Harbor.

I've tested with the EE Harbor code also, but it presents more issues matching this question: Channel Videos Error

**Testing & Debugging:**

Following some of the similar threads, I've double checked and the cache folder is accessible. I've dumped the $data payloads that are passed into the save() and post\_save() functions in the ft.channel\_videos.php file. The issue seems to lie here. Data is blank within post\_save() as it's attempting to retrieve the data from the ee cache. I don't believe it's successfully writing to the ee cache folder even though it's writable and other plugins aren't having similar issues.

**Also to Note:**

When installing the plugin on a site with PHP 7+ . (Required by EE4), there are numerous PHP issues, to do with direct assignment of the instance, requiring a change from:

```
// Creat EE Instance
$this->EE =& get_instance();

```

to:

```
// Creat EE Instance
$this->EE = get_instance();

```

**Request:**

What could be happening when saving? Support will currently be slow while EE Harbor acquire Dev Demon, and I have a ticket in but urgently need to fix a live site. I will add new info as I come across it while debugging.

# Answer
Turns out, it's not compatible with EE4 based on the way EE4 handles fields in the DB. It's being handled by EE Harbor but is a low priority task as it's a free plugin.
> 0 votes

---
Tags: channel, cache, channel-videos
---


title: Model service filtering by date

text:
# Question
Title: Model service filtering by date
I have recently started using the model service to query channel entries.

```
$query = ee('Model')->get('ChannelEntry')
                    ->filter(...);

```

I have been using EE's documentation to get by for most queries, but am now stuck.

I need to filter entries where a field matches a specific date. There is no mention of this in the documentation.

Previously, when I was able to query channel entries with a database call, I was using the following in a where clause:

```
 DATE_FORMAT(from_unixtime(field_id_xx),'%d%m%y')

```

Does anyone know of how this can be achieved using the model service?

# Answer
```
$data = ee('Model')->get('ChannelEntry')->filter('field_id_103', '>' , '1536677819');

```

This code works for me. Where `field_id_103` is my field ID and 2nd parameter is operator (\> , \<, \>=, \<= etc.) and last parameter is db value that needs to check.
> 1 votes

---
Tags: channel-entries, add-on-development, query
---


title: Email Contact form not sending message

text:
# Question
Title: Email Contact form not sending message
Running EE 3.5.16

With the following code for the contact form on a website I am not receiving the email. I have confirmed by direct email that the recipient add

```
{exp:email:contact_form
        user_recipients="no"
        recipients="name@mydomain.com"
        replyto="yes"
        return="/"
        charset="utf-8"}

        <p><label for="from">Your Email:
        <input {if logged_in}type="hidden" value="{member_email}"{/if} {if logged_out} type="text" value=""{/if} id="from" name="from"  /></label></p>

        <p><label for="subject">Subject:
        <input type="text" id="subject" name="subject" size="40" value="" /></label></p>

        <p><label for="message">Comments:
        <textarea id="message" name="message" rows="18" cols="40"></textarea></label>
        <div class="clearer"></div>
        {exp:honee class="beez"}
        <input class="submit" name="submit" type='submit' value='Submit' />

{/exp:email:contact_form}

```

# Answer
might be a stupid one, but is the email addon installed?
> 0 votes

---
Tags: ee3, email-contact-form
---


title: Create an entry from an extension?

text:
# Question
Title: Create an entry from an extension?
Is it possible to use the model service to create a new entry?

I have been using the model service recently to update and delete channel entries, but can't figure out how to create.

```
$update_query = ee('Model')->get('ChannelEntry', $id_to_update)
                           ->first();

$update_query->set(array(
    'field_id_x' => 'Content',
    'field_id_x' => 'Content'
));
$update_query->save();

```

# Answer
Yes, obviously it is possible to use the model to create a new entry. To create a new entry using model you should follow below syntax.

```
$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->set($entryFieldArray);           /* Array of entry_data */
$entry->title = $title;
$entry->url_title = $url_title;
$entry->entry_date = ee()->localize->now;
$entry->edit_date = ee()->localize->now;
$entry->save();

```

This way by using `ee('Model')->make('ChannelEntry')` you can create new entry. I hope this will works for you.
> 2 votes

---
Tags: channel-entries, add-on-development, query
---


title: Upgrade from EE1 to EE4

text:
# Question
Title: Upgrade from EE1 to EE4
I've got an old client that's still on EE1 (I know!). They need to move server and will likely have to be on PHP7 which obviously means an upgrade.

What's the best approach here? I guess I need to upgrade EE1 \> EE2 \> EE3 \> EE4? And how do I even get a copy of EE2?!

The site also uses a bunch of third-party plugins that I expect will be tricky too (NGen file field, Freeform, SL Google Map etc). Would I need to upgrade each of these at each step to a version which works with each EE version?

And finally, is this going to be insanely time-consuming – would I be better off rebuilding and trying to export/import data (if I can find an EE1 export plugin...)

Thanks for any tips!

# Answer
> 1 votes
This will be very time-consuming if you proceed.

Since most of the third party add-ons for EE1 are either out of development with no updated version or hard to obtain, you either own those old add-ons yourself and upgrade them yourself (so *lots* of development time), or you refactor your installation to not use them (*lots* of development time).

Basically, updating a CMS that old will be a rebuild anyways.

As for updating third-party addons with EE upgrades, please read the documentation:

https://docs.expressionengine.com/latest/

That site has documentation for all versions of EE that includes **when** you should upgrade third-party add-ons when jumping EE versions. For each individual third-party add-on, you'll have to try and dig up their documentation on **how** to update them, although most add-ons are updated in similar ways.

As for where to get EE2, if you own a license for it or buy a new license, you can download EE2.9.11 from the `Purchases` section of expressionengine.com after you log in.

---
Tags: upgrade, ee1, ee4
---


title: Optimising Solspace Super Search

text:
# Question
Title: Optimising Solspace Super Search
We have an EE2 on which there is a lot of content, there are several thousand entries, and within the entires each body field has 500+ words.

We are using Solspace Super Search, and results take 5+ minutes to render, I have looked in the documentation but I couldn't find any optimisation options, the only thing I could find in the 'Preferences' is the caching, which I have set up.

I've also added a from date, this helps immensely but obviously filters out older results.

Is there anything else I can do to optimise searching, placing indexes on tables etc, or limiting results by relevance?

# Answer
Take a look at the search terms and index tables in the db. They can get quite bloated (like \> 1million rows ). Also, I'm not sure which method does it, but it runs an optimize table against it as well. Back in the day, we commented that out. Working against that large table, can really slow SS down.
> 0 votes

---
Tags: supersearch
---


title: Can I cache templates indefinitely?

text:
# Question
Title: Can I cache templates indefinitely?
For each template in its Settings, we have Enable Caching? and Refresh Interval. I want to enable caching, but since my content is pretty set, want it to serve cache forever. (At least until the "clear cache" events happen or I manually flush cache.) Does leaving the Refresh Interval to blank do this? Or should I use a really high number? Using EE 4.3.4.

# Answer
> 2 votes
You can set the template refresh to a really high number (e.g. 14400 minutes which is 10 days), or you can change to using a static cache - for example the one that is built in to the stash add-on.

The possible advantage of keeping the EE4 cache with very high numbers is that it works, that it is easy to implement, and that you get (fairly crude) cache-busting built in. However basically if you touch anything to do with templates (and if you have it set so entries) EE will kill the **entire** cache - so if you do ever change an entry it will automatically clear / reset the cache (which might be helpful). But on an active site this means almost certainly you won't be able to keep a cache for much of the time...

There are two kinds of caching built into Stash:

* One which is a bit like the EE one - you can cache within pages, whole pages, and leave bits of pages uncached. It too works, is quite a lot more work to setup (you have to add tags to each template) and unless you buy the Mustash add-on you get no cache-busting control at all (other than EE style "nuke the entire cache").
* The other is a static cache - which builds a set of html snapshots of your pages as they are served (indexed on the URL pattern): it uses a modified .htaccess file and if a URL request matches a page already in the cache it simply sends back that HTML, not needing to even wake EE up. The upside of this is that it is very fast (as no EE type stuff is required), but the downside is it makes it harder to include dynamic elements in your pages (it is an 'all or nothing' option - so if you want interactive elements they have to be included as AJAX type stuff on the page). The Mustash add-on provides some cache-busting options, and you can actually just manage the cache manually (the HTML files are stored with meaningful names in a standard hierarchical folder structure that matches your website structure).

If your site tolerates it, I would suggest you check out the static cache option. Default for both options above is file based caching, but both support other caching schemes if such are available to you.

HTH

---
Tags: cache, ee4
---


title: Accordion Feature Not Working

text:
# Question
Title: Accordion Feature Not Working
Hello—the dropdown accordion feature on this linked landing page on our site is not working. When you click the dropdown button, the accordion feature only stays open for a split second. This is a new glitch! Does anyone have any feedback on what may be causing this issue and how we may troubleshoot it? Thanks!

# Answer
If you are not a developer, you need a developer's help. Here is what is going on:

On the drop-down container elements, you have a class called `visually-hidden`, and the combo looks like this:

```
<style>
.visually-hidden {
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
}
</style>

<dd class="accordion-content visually-hidden" style="display: block;">
    ...hidden drop-down
</dd>

```

So it is hiding a block element by positioning it very far off of the visible area of the rendered document. When you initiate the drop-down expanding, the JS/library you are using removed the `visually-hidden` class from the drop-down container element, and the animation occurs as we would expect. But when the animation finishes, the `visually-hidden` class gets reapplied to the the drop-down container element, essentially re-hiding it and causing the drop-down visual area to re-collapse.

So whatever JS/JS library/jQuery library code you are using to script that UI interaction is incorrect.

I think this is a little broken past that from an engineering prospective (the path to allowing the container to be visible, enabling the animation, and then reverse in some manner).

Can you post the related code to how this accordion feature works? This will help us help you. It isn't clear how this is even ExpressionEngine related, but I still want to help.
> 1 votes

# Answer
you might have asked this question in the wrong user group. https://expressionengine.stackexchange.com/tour

Apart from that, your dropdown works as expected in Chrome. Mac Version 69.0.3497.100 (Officiell version) (64 bitar)
> 0 votes

# Answer
It is hard to know for sure what is going on - but I can see the error using Firefox 62 (Mac).

I would suspect that part of the problem is that the site is using jquery 1.12. This version of jQuery is quite old, and not being developed. It is quite possible that recent changes in some browsers (say Firefox) have caused it to respond to the old jQuery script in unexpected ways, while in others (e.g. chrome) different development paths mean that these changes in behaviour have not shown up.

It may be that you can find a rearrangement of the jquery / javascript driving your accordion that will side-step this problem, but a better long-term fix would be to begin thinking about updating your site to work with a newer (and supported) version of jQuery. The latest version is 3.3.1

HTH
> 0 votes

---
Tags: templates, template-layouts
---


# Question
Title: Disallowed Key Characters error when moving EE website to another server
I want to move an EE 4.3.5 website from a development server to a production server. In this purpose, I have applied the steps presented here in the EE documentation.

But, when I want to access the Control Panel on the production server, the browser displays a Disallowed Key Characters error.

I have applied the the first answer to this post to have more info about the error. At line 997 of system/ee/legacy/core/input.php, I have added the $str variable into the $error variable.

Now, the browser shows : **Disallowed Key Characters exp\_last\_visit**

It appears that the error comes frome the exp\_last\_visit value, which seems to be a cookie.

How to fix this ?

# Answer
This usually happens when there is a clash between the cookies. Give clearing your browser cookies, or at least delete the EE ones a try. A good way to thwart this is to set a unique cookie prefix/domain for the site/server. you can find the cookie overrides here: https://docs.expressionengine.com/latest/general/system\_configuration\_overrides.html I's start with cookie\_domain and cookie\_prefix
> 2 votes

# Answer
Thank you Jim, but that did not solve the problem.

I have created another test domain to try what your suggested and moved my website to it. I have added the cookie\_domain and cookie\_prefix overrides in the config.php file but the "Disallowed Key Characters" error still displays.

Fortunately, my production website is OK. Yesterday, I copied and pasted the files from dev to prod directory with Plesk, instead of downloading then reuploading by FTP. With this method, I don't have the error. But I just can't explain why.

Anyway, I will report a bug. Moving a website from a directory/server to another should not generate this kind of issue. I have worked on several websites under EE2 and that never happened. This is my first EE4 and I am very badly surprise to meet such an issue.
> 0 votes

---
Tags: codeigniter, cookies
---


title: Database access from another server

text:
# Question
Title: Database access from another server
What format is the database stored? Can the database be accessed from a website on another server?

Thanks for your help

# Answer
> 1 votes
EE stores its data (by default) in a MySQL database using InnoDB type tables (earlier versions of EE used MyISAM type tables): MySQL or Percona are listed as requirements for the latest versions of EE, but it may work off other similar SQL type databases (e.g. MariaDB).

Accordingly, as remote access operation is supported by MySQL, it is perfectly possible to run EE with data from a different database server (either co-located or remote), and / or to access EE's datatables directly from remote points.

HTH

---
Tags: database
---


# Question
Title: Channel Entries: Showing #-# of # Total (Outside Tags/Pagination)?
What's the best way to display "Showing #-# of # Total" on channel category listing page outside -- and before -- the {exp:channel:entries} tags and pagination?

Here's a PHP solution -- but it's inside the pagination:

Show currently displayed results and total results in pagination

Any help would be greatly appreciated. Thank you.

# Answer
**Original answer updated to use Layout Variables**

Pagination by definition is predicated on an understanding of three things

* how many items there are to be displayed,
* the index # of the first item to be visible in the window, and
* how many are currently visible in the sliding window to that collection of items being used for display.

You will already know the third value as you will have set it in the `limit` parameter of your channel entries tag, but for the other two we need to extract this information from your live channel entries call block. Fortunately EE exposes this information:

With this information you can construct the pagination block manually. There are a variety of ways to do this (Derek Hogue's php solution being just one such). An approach that avoids embeded php would be to use Caddis' excellent Math add-on for EE.

First we need to grab info on what is being displayed currently in the channel entries block - you could use stash or layout variables for this.

To use Layout Variables you first need to create a new template with just your `{exp:channel:entries}` tag in it (i.e. the tag that generates the output you want to create the pagination string for). Keep your original template (we'll need to modify that in a bit), so choose a new name for the new layout variable one.

Start your new template with a tag to call the original template as the 'next' one in the processing order, and then grab pagination information from the channel entries call. Something like...

```
{layout="layout_group/original_template"}

{exp:channel:entries ... blah ... limit="YOUR_LIMIT_VALUE"}
{if count == 1}
   {layout:set name="paginate_window_start"}{absolute_count}{/layout:set}
   {layout:set name="paginate_total_results"}{absolute_results{/layout:set}
{/if}
{layout:set:append name="channel_entries_output"}
                 ... blah ...
{/layout:set:append}
{/exp:channel:entries}

```

When this template is processed two single layout values will be saved from the `{if}` statement for loop 1, and an array containing one entry output from each loop of the channel for this pagination state.

Now we go to the original template. This template now has the information we captured in the previous template available as layout variables.

We can replace the original `{exp:channel:entries}` tag with a call to dump out the content of our layout variable array `channel_entries_output` \- something as simple as:

```
{layout:channel_entries_output}
  {value}
{/layout:channel_entries_output}

```

Then somewhere else in your template you will be able to do the maths to work out the values for your pagination string. Something like (using Caddis Math):

```
<p>Showing
{layout:paginate_window_start}
-
{exp:math
  formula="[1] + YOUR_LIMIT_VALUE"
  params="{layout:paginate_window_start}"
}
of
{layout:paginate_total_results}
Total</p>

```

Of course you may need to do some fine-tuning of this - it is not clear from your question how you control the pagination output of the channel if not via the pagination block - depending on how you do this may affect how you set up the processing. But the general idea hopefully holds.

HTH
> 0 votes

---
Tags: channel-entries
---


title: User area and file sharing?

text:
# Question
Title: User area and file sharing?
is there a way to enable users to upload files that only the user is able to see/download.

Admin needs to be able to manage the user's files and upload/delete these from the backend.

So a user registers an account -\> can access user area with his files and upload/download -\> admin can upload files for that user and manage user's files

Each user had his own area

Any addons that can do that?

Thanks

# Answer
Your requirement can be achieved by Smart Members Pro and Channel Images plugin. I am assuming that your website have `User section` from front-side and `Admin section` from beck-end to manage that `User section`.

Using **Smart Members Pro** :-

You should create `Member's Registration, Login, Update profile, Change password, Forgot password and reset password` by using this plugin. *For member area in EE this plugin is supreme.* So, that you can create separate member area for every registered User.

Using **Channel Images** :-

After making any **Channel** (having Channel Images field) to store images, You should make front-end form to upload the images by `logged_in` User by using `Channel form`. So, that user can upload the Images from front-end.

By this way **Member section** can be handled by `Smart Members Pro` and **Upload images** section can be handled by `Channel Images`. And to **assign Images to any member** you can create `Simple Text-box` and store respective **member-id** into it. Combination of these two plugin can achieve your requirement for sure.
> 1 votes

---
Tags: add-on
---


# Question
Title: Are .htaccess files required for EE install?
I'm discussing with my sysadmin about whether to allow .htaccess files. I noticed all over the EE file tree there are .htaccess files to prohibit access to files, such as to system/user/config/config.php. But they also appear to have built-in direct-access controls, such as:

if ( ! defined('BASEPATH')) exit('No direct script access allowed');

So, .htaccess files a good idea to have on? Using EE 4.3.6.

# Answer
No, `.htaccess` file is not needed for EE install. If you don't make `.htaccess` file then also EE will run. But, it is advisable to keep `.htaccess` file for **removing the index.php from URL, leverage browser caching** and **gzip compression**.

`.htaccess` files are used to override settings which is set in the apache configuration. If you don't want to change, then you don't need (and shouldn't have) an `.htaccess` file.

`.htaccess` files are specifically for people who don't have permission to root.
> 3 votes

# Answer
htaccess is not needed, however, to remove the index.php from the url you'll need it Also for setting cache control headers it's usefull as wel as for caching and gzip output/extraction
> 2 votes

---
Tags: htaccess
---


# Question
Title: Simple Search results limiting not working
The search is working fine however the search results are not being limited. Any ideas?

```
    {exp:search:simple_form
        channel="about|approach|blog|job-ads|solutions|who_we_help"
        search_in="entries"
        results="3"
        result_page="search"
        no_result_page="search/no_results"
    }
        <input type="hidden" name="XID" value="{XID_HASH}" />
        <input id="keywords" name="keywords" placeholder="TYPE AND PRESS ENTER" type="text">
    {/exp:search:simple_form}

```

# Answer
I've just tried and everything looks fine to me. The only thing I can think of that was different in my code is the results\_page parameter, I've got search/results instead of just search.

My code:

```
{exp:search:simple_form
    channel="my|channels"
    search_in="entries"
    results="3"
    result_page="search/results"
    no_result_page="search/no_results"
  }

```

Maybe if you change your's to search/index?
> 0 votes

# Answer
If you can't add a limit= parameter, you can inside your {exp:search:search\_results} tag limit by count:

```
{exp:search:search_results}
  {if count <= 3}
    {title}
  {/if}
{/exp:search:search_results}

```
> 0 votes

---
Tags: search, simple-search
---


# Question
Title: Infinite scroll and pagination on ee?? Anyone has this working?
Good day all I have had this issue for a while now and can't find really good updated techniques to create the infinite scroll and pagination function where clicking 'load more' loads entries beneath until there are no more entries. I need some simple code that would make this work, currently my code basically just gives me entries on a new page but i want it to load on the same page beneath each other. Has anyone succesfully achieved this hassle free?

Who ever has the correct answer I will tell the world of your tale and everyone else will call you king/queen of EE Pagi-Nation! Here is my terrible coding below!

PS: I have tried justin long's method and it did not work for me, I mailed him too.

```
<div class="col" id="blog-container">
        {exp:channel:entries
            channel="blog"
            dynamic="no"
            orderby="date"
            limit="2"
            status="open|tall|regular"
            paginate_base="embed/ajax_scroll"
        }

        {if no_results}
            <div class="entry">
                <article style="min-height: 600px;">
                    <header>
                        <h1>No Results</h1>
                    </header>
                    Check back soon for more blog posts.
                </article>
            </div> <!-- /.entry -->
        {/if}
        <div class="entry">
            <article>
                <header>
                    {title}
                </header>
               {blog_summary}
            </article>
        </div> <!-- /.entry -->

        {paginate}
        <p class="morePosts">
            {if next_page}<a href="{auto_path}" class="more" id="next">See More Posts</a>{/if}
        </p>
        {/paginate}
        {/exp:channel:entries}
    </div> <!-- /.col -->

      <script type="text/javascript" src="/httpdocs/static/js/jquery.infinitescroll.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $('#blog-container').infinitescroll({
                  navSelector : "p.morePosts",
                  nextSelector : "a.more",
                  itemSelector : ".entry",
                  contentSelector: "#blog-container",
                  extractLink: true // This is crucial if you want it work properly. Setting this to false or excluding it will not allow the script to work with EE
             })

        });

        // Unbind normal behavior
        $(window).unbind('.infscr');

        // Bind normal behavior to the click function and prevent the browser from redirecting to the URL.
        $('a#next').click(function(){
            $(document).trigger('retrieve.infscr');
            return false;
         });

    </script>
</div>

```

# Answer
No reason why you can't get an infinite scroll working in EE. Though really you don't need all the overhead of the infinite scroll plug-in, which forces its particular requirements on you as well. A small bit of jQuery can do this just as well. You just need to add one additional wrapper to your markup so that you can target the content you want to load via Ajax, and be able to append it to your parent container.

So keep all of your HTML markup the same, but just add one more `div` of inside of your content container.

Also, you have `paginate_base="embed/ajax_scroll"` \- remove that, just let the pagination links point to the same page you're on. This way they'll work even if javascript is disabled.

```
<div class="col" id="blog-container">
    <div class="ajax-wrapper">

    ... all of your markup, without the javascript ...

    </div>
</div>

```

Then, load this javascript:

```
<script type="text/javascript">
    $(document).ready(function()
    {
        $('.morePosts').on('click', 'a', function(e)
        {
            // Don't follow the link
            e.preventDefault();

            // Create a loading message and add it in place of the link
            loadingMessage = $('<p class="loading">Loading...</p>');
            $('.morePosts').replaceWith(loadingMessage);

            // Fetch the next page
            $.get($(this).attr('href'), function(data)
            {
                // Only grab the part of the page we want
                content = $(data).find('.ajax-wrapper').hide();

                // Add it to the DOM
                $(content).appendTo('#blog-container');

                // Remove loading indicator
                $('.loading').fadeOut('fast').remove();

                // Fade-in our new content
                $(content).fadeIn('fast');
            });
        });
    });
</script>

```
> 7 votes

# Answer
I was having some issues, where by the second time I clicked the pagination button the preventDefault was getting ignored.

```
<div class='journal' data-behaviour='masonry loadMoreJournals'>
    <div class="ajax-wrapper">
            {!-- ee loop --}
 </div>
</div>

```

and the js,

instead of

$('.journal').on('click', 'a', function(e){ stuff })

this

$('.journal').delegate('.view-more', 'click', function(e) { stuff })
> 1 votes

# Answer
On the off chance that someone else finds this and has the same issue as magicspon in which the second click ignores the preventDefault business, this code works on all clicks

```

  $(document).ready(function()
  {
      $('.morePosts').on('click', 'a', clickHandler);

      function clickHandler(e) {
          // Don't follow the link
          e.preventDefault();

          // Create a loading message and add it in place of the link
          loadingMessage = $('Loading...');
          $('.morePosts').replaceWith(loadingMessage);

          // Fetch the next page
          $.get($(this).attr('href'), function(data)
          {
              // Only grab the part of the page we want
              content = $(data).find('.ajax-wrapper').hide();

              // Add it to the DOM
              $(content).appendTo('.calendar-list');
          $('.morePosts').on('click', 'a', clickHandler);

              // Remove loading indicator
              $('.loading').fadeOut('fast').remove();

              // Fade-in our new content
              $(content).fadeIn('fast');
          });
      }
  });

```

A friend (whom I now owe many beers) added the click handler bit so the .morePosts link always has the preventDefault applied.
> 1 votes

---
Tags: pagination
---


# Question
Title: Why do I keep getting automatically logged out of control panel?
I have never had this with older versions of EE but I just began working with the latest version, 4.3.6, and I keep getting automatically logged out of the control panel after saving changes to templates. I will click Save and wind up back at the login page. Sometimes when I attempt to log back in without refreshing the login page I get an error message "error: this form has expired. please refresh and try again."

I have found the proposed solutions to this problem for versions 2.X and have tried them but they have not worked. I have not seen any solutions specifically for the latest version.

Thanks.

# Answer
> 0 votes
Ok, turns out the solution that seems to be working for me was to add `$config[‘cp_session_type’] = “s”;` to my config.php file.

Although I don't know if this creates some type of security risk.

---
Tags: control-panel, ee4
---


title: Orderby Custom Field (What is wrong?)

text:
# Question
Title: Orderby Custom Field (What is wrong?)
This is a simple event listing. I want the output to list by "touring date" which is a custom date field. However, it doesn't seem to work.

```
  {exp:channel:entries channel="touring_calendar" dynamic="no" orderby="touring_date_and_time" sort="asc"}
  <div class="touring-details">
    <h2 class="touring-city">{touring_city_state}</h2>
    <h2 class="touring-show">{touring_show_name}</h2>
    <h2 class="touring-venue">{touring_venue_name}</h2>
    <h2 class="touring-date"> {touring_date_and_time  format=" %F %j, %Y; %g:%i %a"}</h2></div>
  {/exp:channel:entries}

```

It seems to be listed by "entry date" not the custom date field I created. I am stuck!

# Answer
So I ran a test for you. I added a date field to a channel in my sandbox. I added this data to several entries. I can control the ordering based on that field with:

```
{exp:channel:entries channel="pages" orderby="datetest" sort="asc"}
{count} - {title}<br/>
{/exp:channel:entries}

```

This works as expected. You can watch the order flip when the sort parameter is changed.
> 0 votes

---
Tags: orderby
---


title: Issue with output class

text:
# Question
Title: Issue with output class
So i'm trying to output the content of a template in xml and saw that the documentation mentioned an output class with functions like set\_content\_type (https://docs.expressionengine.com/latest/development/legacy/libraries/output.html). When I try to call this function using:

> ee()-\>output-\>set\_content\_type('xml');

the page loads with an error:

> "Call to undefined method EE\_Output::set\_content\_type()"

Other functions of the output class such as "parse\_exec\_vars" work fine. Am I forgetting something that allows this function to be used? Also I am currently using expressionengine4

# Answer
Maybe it's not relevant but in the Add-ons there's XML encode. Is it installed?
> 0 votes

---
Tags: content
---


# Question
Title: Search Multiple Fields with one keyword input in a form with other field searches
I've seen variants of this question but nothing that matches. There is a form that has multiple dropdown category selectors and a few keyword inputs. This is the field which I would like to also search the entry title.

```
<input type="text" name="search:resource_additional_names:rhn_historical_name" value="{low_search_keywords}" placeholder="Keywords">

```

If I try something like:

```
<input type="text" name="search:resource_additional_names:rhn_historical_name|search:title" value="{low_search_keywords}" placeholder="Keywords">

```

The results page throws an error. Is there a way to do this?

# Answer
> 0 votes
The solution for me was to create a new collection with only the fields I wanted to search and use a keyword input:

```
<input type="text" name="keywords" value="{low_search_keywords}">

```

I had to make sure the collection is referenced in the search and results pages and more importantly, one of the fields I needed to search was a Matrix field and the column that was to be searched needed to have "Is col searchable?" checked and then all entries needed to be resaved.

---
Tags: low-search
---


# Question
Title: Uploading images in CP using ee:_shared/form via custom addon
I created a module for EE2 a few years back and I'm in the process of making this compatible with EE3/4. I'd ideally like to make use of the `ee:_shared/form` (Shared Form View) and I'm 90% there but struggling with image field types. Text fields are working perfectly fine.

**user/addons/module\_name/mcp.module\_name.php**

```
public function add()
{
    if ( ! ee()->cp->allowed_group('can_access_content'))
    {
        show_error(lang('unauthorised_access'));
    }

    $vars = array(
        'base_url'              => ee('CP/URL', 'addons/settings/' . $this->lower . '/update'),
        'cp_page_title'         => lang('add'),
        'save_btn_text'         => 'btn_add',
        'save_btn_text_working' => 'btn_saving'
    );

    $vars['sections'] = array(
        $this->get_sections()
    );

    return ee('View')->make('module_name:form')->render($vars);
}

// $this->get_sections() returns the following nested arrays
// This is working fine for text fields
$sections[] = array(
    'title'  => $field,
    'fields' => array(
        $field => array(
            'type'     => $type,
            'value'    => $value,
            'required' => $required
        )
    )
);

```

**user/addons/module\_name/View/form.php**

```
<?php $this->embed('ee:_shared/form'); ?>

```

I'm guessing I need to use the `ee('CP/FilePicker') Service` for *something* but the documentation is very vague.

I appreciate this is an incredibly vague query but does anyone have experience with setting up a file/image field using EE's shared form view?

# Answer
> 0 votes
I've finally got to the bottom of this.

I needed to create a file picker reference and set that as the content of an HTML field type. The file picker allows you to search, select and upload images and stores the file's ID as the value of the field. I've added the full commented code below.

**addons/module\_name/mcp.module\_name.php**

```
public function add()
{
    // Options for shared view
    $vars = array(
        'base_url'              => ee('CP/URL', 'addons/settings/module_name/update'),
        'cp_page_title'         => lang('add_location'),
        'save_btn_text'         => 'btn_add_location',
        'save_btn_text_working' => 'btn_saving'
    );

    $image_id    = 123; // Get this when editing or leave blank when adding

    /* Begin image stuff */
    // Create a new File Picker
    $file_picker = ee('CP/FilePicker')->make();

    // Create a link from File Picker (more options on link below)
    // https://docs.expressionengine.com/latest/development/services/filepicker.html
    $link        = $file_picker->getLink('Browse Images')
        ->asThumbs() // Show images as thumbnails
        ->withValueTarget('location_image'); // This needs to match both the name and id attribute of the hidden input

    $vars['sections'] = array(
        'image' => array( // Will add a section to the form with the title 'Image'
            array(
                'title'  => 'change_image', // Add this to your lang file
                'desc'   => 'change_image_desc', // Add this to your lang
                'fields' => array(
                    'location_image' => array(
                        'type'    => 'html',
                        'content' => '<input type="hidden" name="location_image" id="location_image" value="' . $image_id . '">' // Create a hidden field here with the id and name matching withValueTarget
                    ),
                    'image_picker'   => array(
                        'type'    => 'html',
                        'content' => $link->render() // Render the image picker
                    )
                )
            )
        )
    );
    /* End image stuff */

    return ee('View')->make('module_name:form')->render($vars);
}

```

**addons/module\_name/View/form.php**

```
<div class="box">
    <?php $this->embed('ee:_shared/form') ?>
</div>

```

**addons/module\_name/language/english/lang.module\_name.php**

```
$lang = array(
    'add_location'      => 'Add Location',
    'btn_add_location'  => 'Add Location',
    'change_image'      => 'Change Image',
    'change_image_desc' => 'Upload or change the attached image'
);

```

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


# Question
Title: Search on ExpressionEngine 3 giving image/file URL's as the excerpt
I have a site on EE 3.5.17. I am using the basic search feature provided and have a template which outputs results as follows:

```
{exp:search:search_results}
    <h4><a href="{auto_path}">{title}</a></h4>
    <p>{excerpt}</p>
{/exp:search:search_results}

```

When I do certain searches I get a URL to images (and sometimes other resources like PDF's) in place of `{excerpt}`. For example the output might be:

```
<h4><a href="https://example.com/whitepaper/foo">Whitepaper: Foo</a></h4>
<p>https://example.com/pdf/foo.pdf</p>

```

When I visit these pages there is more on them than just a downloadable PDF. For example the structure of the page above (`/whitepaper/foo`) contains a `<h1>`, followed by a couple of paragraphs of text, and finally a downloadable file (`/pdf/foo.pdf`).

I can't see any way to override what the search facility uses as the `{excerpt}`. Is this possible?

Furthermore, the search results appear in a seemingly random - and not at all useful - order.

We are not upgrading this particular site to EE 4.x, and I don't know if the search in that is any better?

On a previous version of this site we used Google Site Search (i.e. where you have a form that scrapes results from Google for our domain, `search-term site:example.com`) but it looks like this has been discontinued.

Please can someone advise on how they've dealt with this situation as I imagine it's quite common.

# Answer
You should check your channel's settings for "Search excerpt". That lets you define a field from which to pull the excerpt.
> 2 votes

---
Tags: search
---


# Question
Title: Expression Engine 4 / Assets numeric value out of range for column 'filesize' error
We use Expression engine 4 and the latest Assets. After adding a new external source (AWS S3), and trying to update index, I'm getting an error:

"Numeric value out of range value for column 'filesize' at row 43"

I'm guessing this is because we have giant files in our bucket? Just looking for a way to get around this and be able to index our external source.

# Answer
So this seems to be an issue with the `int` range of the column:

https://stackoverflow.com/questions/14284494/mysql-error-1264-out-of-range-value-for-column

It looks like you'll need to experiment with changing that column type to `VARCHAR`, or try making sure it is an unsigned `int` if it isn't already.

This could break stuff so test on a development server first. But I would suggest going right to EEHarbor support with this info as using that column as an `int` seems to be a bug in the software and they may need to provide an update that changes that column data type and makes sure the add-on code handles the changed data type correctly (probably casting a string that stores file size to an integer in PHP).

**Edit**

I just checked and that column is an unsigned integer type, so you have some big files going on. EEHarbor will need to do what I said to make the add-on compatible with customers who have really big files (from any source, not just AWS S3). Contact them.
> 0 votes

---
Tags: assets, ee4-upgrade
---


# Question
Title: Pull random 10 entries without duplicating every time when ajax calls
Possible to pull random 10 entries (without duplicating entries) with ajax everytime when scroll to the bottom, right now it loads random 10 entires but it duplicates and some entries never shows up. Any ideas? thanks

index.html:

```
{exp:channel:entries channel="channel_A|channel_B|channel_C" orderby="random" limit="10"}
  {content}
{/exp:channel:entries}

```

ajax/index.html

```
{exp:channel:entries channel="channel_A|channel_B|channel_C" orderby="random" limit="10"}
  {content}

  {paginate}
    {pagination_links}
      <ul class="lepaginate">
        {page}
          <li><a href="{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
        {/page}
      </ul>
    {/pagination_links}
  {/paginate}

{/exp:channel:entries}

```

jquery:

```
  var counter = 10;

  $(window).scroll(function() {
    if($(window).scrollTop() + $(window).height() == $(document).height()) {

        var response;
        $.ajax({ type: "GET",
          url: ""+document.location.origin+"/ajax/P"+counter+"",
          async: false,
          success : function(text) {
            response = text;
          }
        });

        counter += 10 ;
        newItems = $(response).appendTo('.grid');
        $grid.isotope('appended', newItems );

          var $grid = $('.grid').isotope({
            masonry: {
              columnWidth: 360,
              gutter: 30
            }
          });

    }

  });

```

this is using pagination, so it loads like '/ajax/P10' '/ajax/P20' ..., etc

# Answer
> 2 votes
Two approaches come to mind, the first is to load everything (all results) and only show X at a time (JavaScript) based on your own custom pagination or lazy loading effect. But that means you'd still be sending to the browser all the raw html initially, so might have performance issues.

How `channel:entries` works with the `limit` parameter in ExpressionEngine is by running a full search and getting all results back as a delimited list of entry id's based on all your search/filtering options. It then runs a second query to extract all the information it needs on the limited subset of entries to then be able to parse and present the data in your template.

So the second approach could actually be done a few ways depending on your skill level, but the principle is that you do a minimal query returning the entry IDs for all results (pipe delimited), then retain that as a JavaScript variable feeding the parts of the total results to match the (paginated) page results you require - feed that to your ajax call which in turn populates the entries to be shown in your final channel:entries tag.

Although initially you could use a channel:entries tag to get the full list, it should be better performance to use the `exp:query` tag \- depending on the complexity of your filtering/search parameters. You could then post the required entries (for next page) to the ajax URL, and on the resulting page/template use the `channel:entries` parameter `dynamic_parameters` to use the POST data to automatically populate the `entry_id` parameter on the `channel:entries` tag, therefore only showing the limited entries.

Note that by default `channel:entries` only pulls back 100 results, if you want to pull more, you have to specify the `limit` parameter. From memory, going over 1000 starts to cause massive performance issues.

# Answer
> 0 votes
You can't meaningfully combine `orderby=random` and pagination. Basically what you're doing is this each time:

* Give me 10 random entries
* Give me 20 random entries and ignore the first 10
* Give me 30 random entries and ignore the first 20
* Etc

Hence the duplication - there's no consistency between queries due to the random ordering.

# Answer
> 0 votes
You could , with php, get all the entry\_ids of the displayed entry. And in your ajax exp:channel:entries entry\_id="not YOU ID LIST"

Didn't read you entire post. Then my solution seems impossible.

---
Tags: channel-entries, pagination, ajax, random
---