# Question
Title: Cartthrob: How to set up product that is available for rent OR purchase?
I need to set up a checkout system when certain products say, a camera, can be either purchased OR rented.

I understand how this could be accomplished with separate entries for purchase/rental options. Using price modifiers will handle the different rental options nicely.

Obviously I don't want site admins to have to enter this content multiple times however. Anyone know the best way to approach this?

# Answer
> 1 votes
You could do a few things, all of which include having one entry per product (not needing to separate them).

* Manage rental and purchase prices as a Cartthrob price modifier field.
* Pre-populate matrix or modifier field rows by using some JavaScript in the instructions area.
* Set up fields for purchase prices and rental prices, use a checkbox to indicate whether the product is available for purchase or rent. Then apply the appropriate price on the front-end using the `allow_user_price="yes"` parameter on the `{exp:cartthrob:add_to_cart}` tag, a hidden price input field, and some jQuery.

The downside to using the allow\_user\_price parameter solution, is that if someone really wanted, they could enter their own price by modifying the hidden price field's value using devtools or firebug.

# Answer
> 1 votes
I've set up rentals before of digital goods by writing a simple extension that set the 'Purchased Product' entry to have a expiration date of one week (or any time length really) from the date of purchase. You could do the same for a physical product. I'd share the code with you for this, but unfortunately I am unable to due to licensing restrictions.

I'm guessing you may be dealing with a quantity limitation when renting physical products. Similar to the above suggestion you could have a entry for each instance of a rentable product and change the entry date (via a hook) to a future date each time it's purchased. Possibly better yet you could change the status of the purchased product to 'rented' and once the product is returned you could manually revert it back to 'open'. I don't have any code to support this example - but it's definitely possible.

Good luck!

---
Tags: add-on, cartthrob
---


title: {switch} not working

text:
# Question
Title: {switch} not working
Why wouldn't this work?

am I missing something?

```
<div class="col-70">

        {exp:channel:entries channel="ministries" limit="1" {gv_param_disable_default}}

            <h1 class="section-header">{title}</h1>
            <p>
            <img class="{switch='drop-shadow body-image-right|drop-shadow body-image-left'}" src="{image}" alt="{image_description}" title="{image_description}" width="350"/>

            {page_content}

            </p>

        {/exp:channel:entries}

</div>

```

Update:

Come to find out, the switch does work fine though, I didn't realize it's intended use. It doesn't switch every page load or between each entry on separate pages rather, it switches through the iteration (or loop if you will) of entries when you have more than one entry being listed on a page via a single channel entry tag pair.

A good example of how one might use the switch variable and classes would be Zebra Tables where you are switching between a darker and lighter color for each table row.

# Answer
> 2 votes
surely on a listing of entries you should have dynamic="no" set, like so:

```
{exp:channel:entries dynamic="no" limit="2" channel="ministries" {gv_param_disable_default}}

```

# Answer
> 1 votes
You have a `limit=1` set on the entries tag. So there is only 1 iteration in the loop. For the switch tag to work, it needs to have more than one entry to rotate through the values. Setting the `limit` to `2` or higher will work.

# Answer
> 0 votes
I'm not sure why that's not working to be honest either based on the code you've provided. Someone mentioned the limit and I'm assuming it's safe to say that you do in fact have more than one entry.

Can you try this instead just for kicks and giggles:

`class="drop-shadow body-image-{switch='right|left'}"`

---
Tags: add-on, switch
---


title: Postmaster Hook Parse Error

text:
# Question
Title: Postmaster Hook Parse Error
ExpressionEngine 2.5.2 - Build Date: 20120606 Postmaster 1.2.0

I was wanting to try to create a hook for Postmaster but when I click "add hook" I get the following error.

```
Parse error: syntax error, unexpected T_ENDFOREACH in /var/www/html/teamnet/system/codeigniter/system/core/Loader.php(727) : eval()'d code on line 249

```

# Answer
> 1 votes
I made a number of critical bug fixes to Postmaster's latest developer build this evening. I have test thoroughly and can't any more issues. I created and triggered hooks without issue.

I know I emailed you the updated branch before, but I think you run into new issues which have also been fixed. So... just email support\[at\]objectivehtml.com and I will send you the updated code.

---
Tags: postmaster
---


# Question
Title: Safecracker Registration Password Field Error
I have a simple Safecracker form with email, password and password confirm fields.

I tried filling up the forms with the a password less then 5 characters. When I submitted, I get this error

```
The password you submitted must be at least 5 characters long

```

in field errors.

My question is that, isn't this supposed to be an inline error? If it is not, how do access it in {field\_errors}? I want it to show as an inline error near the field.

P.S. Here is my code, truncated to relevant parts.

```
    {exp:safecracker channel="members" class="form-horizontal" dynamic_title="[email]" error_handling="inline" include_jquery="no" register_member="yes" return="/sign-up/" safecracker_head="no"}

{if global_errors:count > 0}
    <div class="errors group tencol">
        <h3>General Errors</h3>

        <ul class="bullets">
        {global_errors}
            <li>{error}</li>
        {/global_errors}
        </ul>
    </div>
    {/if}

    {if field_errors:count > 0}
    <div class="errors group tencol">
        <h3>Form Errors</h3>

        <ul class="bullets">
        {field_errors}
            <li>{error}</li>
        {/field_errors}
        </ul>
    </div>
    {/if}

...

    <input type="password" name="password" value="{if post:password}{post:password}{/if}" id="password">
    {if error:password != ''}
       <span class="help-inline">{error:password}</span>
    {/if}

```

# Answer
> My question is that, isn't this supposed to be an inline error?

Sorry it took so long to get back with you. Short answer, no.

That's an error from the member registration class, which is a global error. Field errors, or inline errors are validated in CodeIgniter from Safecracker. One those are validated correct, the global error checks are ran. If any errors are found, they are returned.

So procedurally speaking, the field errors have already passed and now the member validation check fails. I think this is a good feature request though.

I think a work around would be to use Safecracker's validation rules to create your own minimum length which causes the field errors to fail when validating. Maybe try something like this:

```
rules:password="required|min_length[5]"

```

*I have not tested this code, but if it fails in Safecracker, I could do the same routine programmatically in the extension. That would be how I solve the problem in a future update*
> 1 votes

---
Tags: forms, safecracker-registration
---


# Question
Title: Page title incorrect on stash paginated results
I'm using Stash and Switchee to build some paginated News entries. However, when I click through to Page 2 and beyond, my page title changes to the latest entry in the CMS. Wondered if anyone had a solution for this?

As you can see from the code below, I have a news index page - which I have created as a Page in the CMS at mydomain.tld/news and then within this same template I'm also building up some paginated results rows of news articles. I set a title value for the index page which works fine (this then gets pulled through to the embedded \_layouts/index page with the tag {exp:stash:get name="title"}.

Content of \_layouts/index;

```
<body id="page mobile-view" class="off-canvas hide-extras {exp:stash:get name='body_class'}">

<div id="size"></div>

<div class="container">

<h1>{exp:stash:get name="page_title"}</h1>

{exp:stash:get name="content"}

</div>

</body>

</html>

```

Content of news/index;

```
{embed="_layouts/index"}
{preload_replace:channel="news"}

{exp:switchee variable="{segment_2}" parse="inward"}

    {!-- News index --}
    {case value="#^P(\d+)$#|''"}

        {exp:channel:entries
            channel="page"
            status="open"
            limit="1"
            {global:channel_disable_most}
        }

            {exp:stash:set name="page_title"}{title}{/exp:stash:set}

        {/exp:channel:entries}

        {exp:stash:set parse_tags="yes" parse_conditionals="yes"}

            {stash:results_rows}
                {exp:channel:entries
                    channel="{channel}"
                    orderby="date"
                    sort="desc"
                    limit="6"
                    dynamic="no"
                    status="not closed"
                    paginate="bottom"
                }

                    <div class="twelve columns other_news">
                        <div class="three columns">
                            <a href="{site_url}news/{url_title}" title="{title}">
                                {exp:ce_img:pair
                                    src="{news_leaderimage}"
                                    height="218"
                                    width="380"
                                    attributes='style="width:100%;"'
                                }
                                    <img src="{made}" alt="{title}" />
                                {/exp:ce_img:pair}
                            </a>
                        </div>
                        <div class="nine columns">
                            <div class="sub-padding3a">
                                <h1 class="title4"><a href="{site_url}news/{url_title}">{title}</a></h1>
                                <p class="paragraph1 date">Added <span>{entry_date format="{global:date_short}"}</span></p>
                                <div class="paragraph1">
                                    <p>{news_summary} <a class="oLink" href="{site_url}news/{url_title}" title="Read More about {title}">» Read More</a></p>
                                </div>
                            </div>
                        </div>
                    </div>

                    {stash:absolute_results}{absolute_results}{/stash:absolute_results}

                    {paginate}
                        {stash:pagination_summary}
                            <div style="width:30%; float:left;">
                                Page {current_page} of {total_pages}
                            </div>
                        {/stash:pagination_summary}
                        {stash:pagination_links}
                            {pagination_links}
                                <div class="refit">
                                    <div class="refit-inner">
                                        {previous_page}<a href="{pagination_url}"><strong>« Previous</strong></a>{/previous_page}

                                        <div class="push">
                                            {page}<a href="{pagination_url}" class="page-{pagination_page_number} {if current_page}selected{/if}">{pagination_page_number}</a>{/page}
                                            {next_page}<a href="{pagination_url}"><strong>Next »</strong></a>{/next_page}
                                        </div>
                                    </div>
                                </div>
                            {/pagination_links}
                        {/stash:pagination_links}
                    {/paginate}
                    {stash:all_items}{absolute_results}{/stash:all_items}
                    {if count == 1}{stash:first_item}{absolute_count}{/stash:first_item}{/if}
                    {if count == total_results}{stash:last_item}{absolute_count}{/stash:last_item}{/if}
                {/exp:channel:entries}
            {/stash:results_rows}

        {/exp:stash:set}

        {exp:stash:set name="content"}

            {exp:stash:get name="results_rows"}
            {exp:stash:get name="pagination_summary"}
            {exp:stash:get name="pagination_links"}

        {/exp:stash:set}

    {/case}

{/exp:switchee}

```

Look forward to any helping fixing this bug.

Thank you. :)

# Answer
> 0 votes
You might have to hard-code the `entry_id` for your `news` entry in the `pages` channel:

```
{exp:channel:entries
  channel="page"
  status="open"
  entry_id="5"
  dynamic="no"
  limit="1"
  {global:channel_disable_most}
 }

```

Or perhaps hard-code the URL title, either directly or with `{segment_1}` (assuming the URL title for the page entry is `news`:

```
{exp:channel:entries
  channel="page"
  status="open"
  url_title="{segment_1}"
  dynamic="no"
  limit="1"
  {global:channel_disable_most}
 }

```

What's happening is that when you leave the index and are on a paginated page (like `/news/P5`), the URL no longer *exactly* matches your index page's **Pages URI** of `/news`. Because there's no exact match, the entries tag does its default behavior and returns the latest entry in EE.

# Answer
> 1 votes
In your example when segment\_2 is empty or P1, P2, etc. you are setting the page\_title, but that particular channel:entries tag is still dynamic (e.g. no dynamic="no" parameter). If there is no entry with a P2 title, that channel:entries tag will fall back to showing a list of entries instead, which you just limit to 1.

The solution is to also set dynamic=no for the P1 and empty segment. However a better solution is to organize your switchee a bit to catch more clear cases.

---
Tags: stash, switchee
---


# Question
Title: Is there a way to not show entries from a sub-category?
I have a category (cat1) with 2 sub-cats (cat1a and cat1b). 19 entries belong to cat1, but 9 are in the sub-cats.

On the 1st level category page (cat1) is there a way to not show the 9 entries that are in the sub-cats?

Sub-categories aren't set in stone either, meaning client will add more sub-cats periodically.

Channel entry tag is being used by the way.

Thanks

# Answer
You may have **Auto-Assign Category Parents** turned on, which automatically assigns the category parent when you choose a child category on save. So when viewing Cat1, all of Cat1a entries will also be displayed since the parent category is automatically set.

To turn off, go to Admin \> Channel Admin \> Global Channel Preferences.

Also, you will need to then go and update the 9 entries and remove the parent category. You can do this in bulk from the edit entries page. Find all 9 entries, click the checkbox next to each, then at the bottom, choose remove categories. Select the category parent to be removed.
> 5 votes

# Answer
Unless I've missed something here could you not simply use the parent\_only="yes" paramater on the channel categories tag?

http://ellislab.com/expressionengine/user-guide/modules/channel/categories.html#parent-only

If you were looking to do something slightly more complex you could always try the GWcode Categories plugin http://gwcode.com/add-ons/gwcode-categories
> 3 votes

# Answer
One answer here (as mentioned) is to disable Auto-Assign Category Parents.

But, on a site where i rely on that setting to be available, i display the entry conditionally inside the categories tag. Say you want entries for category id 20 only, not children of 20, then i use a condition (or switchee) on the parent\_id:

```
{!-- preload replace trick with segment conditional to set default --}
{if segment_2_category_id ==""}
  {preload_replace:my_cat_id="12"}
{/if}
{preload_replace:my_cat_id="{segment_2_category_id}"}

{exp:channel entries category="{my_cat_id}" ...}
  {categories}
    {if parent_id != "{my_cat_id}"}
      {!-- display the entry --}
      {title}
      {item_body}
    {/if}
  {/categories}
{/exp:channel:entries}

```
> 0 votes

---
Tags: categories
---


# Question
Title: How to store data that relates to a channel?
I have a site with a large number of blog channels (literal blogs in this case).

Each channel has a number of pieces of information I need to associate with it - a summary of the channel, an image that displays as a header, a feedburner link, and a couple other text fields.

Currently, I'm storing that information in a matrix in a low variable, and tying it to the channel manually with a text field containing the shortname of the channel.

The problem is that when I use this matrix a lot (for example on a page that outputs entries from every one of my channels) this matrix ends up being hugely inefficient and boosts my memory usage significantly.

So my question is this - how would you store this type of information that relates to a channel as a whole, not an entry?

# Answer
> 2 votes
I would create separate channel for channel metadata and store all data related to blogs as entries in that channel. That will give you a lot of flexibility (as usually with channels).

To associate entries with actual blogs you will need a custom field that will store blog channel name or ID. That can be text field - in that case, you will need to enter name/ID manually. Or, if you're familiar with add-on development, you can create dropdown select fieldtype that would present list of channels (you can develop it using similar existing fieldtype as a base, like this)

---
Tags: add-on, matrix
---


# Question
Title: Selling photos with Store and Channel Images
Embarking on a site that will sell photos. Those photos will be uploaded in bulk using Channel Images. The user will only want to pick their own photo. All photos will cost the same and should be given to the user post checkout by download.

What's the best way to approach?

# Answer
> 1 votes
Haven't used Store but from what I know of it, you should be able to add a product modifier.

Easiest way would be to add a Store field to your channel that has the Channel Images field.

Then you would add a modifier to grab the id Channel Images photo id.

Once customer has paid, you could display their order info, grab that id and run it through a Channel Images tag so they can download it.

If that makes any sense?

---
Tags: expresso-store, image-galleries, channel-images
---


title: problem with conditionals

text:
# Question
Title: problem with conditionals
Trying to have a style sheet only used when the user is not on the home screen. This code in my head section should work, correct?

```
{if embed:loc != "home"}
<style> body {background:url(images/interface/header_bg_slice3.png) repeat-x,
url(images/interface/texture_bg.png) top left, repeat;}</style>
{/if}

```

here is the corresponding code I'm using in the page template:

```
{embed="embeds/html_header" page_title="About Us" loc="about-us"}

```

what am I missing?

# Answer
> 4 votes
Another option would be to avoid using embedded styles and add a class to your body tag based on what page is loaded. Then you can adjust your body background in your stylesheet instead of the templates.

Like vfalconi said, you can often base this off the index not having a segment:

```
<body{if segment_1} class="subpage"{/if}>

```

Then in your stylesheet:

```
.subpage { your styles here... }

```

# Answer
> 3 votes
Have you tried:

```
{if segment_1}...{/if}

```

In most cases, if the user is on the site index, there wouldn't be a segment\_1. Just seems a much more straight-forward approach to what you're trying to achieve (from what I can tell).

# Answer
> 1 votes
Similar to what Jim said but this would give a bit more flexibility:

```
{embed="embeds/_html_head" body_id="your-css-id" body_class="your-css-class"}

```

and then within that embed

```
<body id="{embed:body_id}" class="{embed:body_class}">

```

You can also achieve the same thing with Low Vars (less overhead too)

```
{exp:low_variables:single
var='lv_html_head'
preparse:body_id='home'
preparse:page_title='Home'
}

```

where lv\_html\_head is a textarea Low Variable containing what would be in your embed.

---
Tags: conditionals
---


# Question
Title: SafeCracker: «You must specify a valid entry to edit.»
SafeCracker gives me a Error after submitting an edit-form…

```
{exp:safecracker channel='xy' … entry_id='{segment_3}'}

```
* The URL contains the entry\_id @ segment\_3
* All field-values are included in their respective custom fields
* If I look into the rendered HTML, the entry\_id is all over the place like: `<input type="hidden" name="entry_id" value="15771">` and others (RET, URI) … ditto for the correct values for author\_id, channel\_id, site\_id etc. (see below)

If I submit the form, the following error gets displayed.

> You must specify a valid entry to edit.

BUT an interesting fact: the entry gets saved anyway!

*System: EE 2.5.5*

**EDIT:** All the hiddenFields:

```
<input type="hidden" name="ACT" value="21">
<input type="hidden" name="RET" value="http://domain.com/dir/dir2/15771">
<input type="hidden" name="URI" value="dir/dir2/15771">
<input type="hidden" name="XID" value="">
<input type="hidden" name="return_url" value="dir/dir2/success/15771">
<input type="hidden" name="author_id" value="1">
<input type="hidden" name="channel_id" value="16">
<input type="hidden" name="entry_id" value="15771">
<input type="hidden" name="site_id" value="1">
<input type="hidden" name="return" value="dir/dir2/success/15771">
<input type="hidden" name="allow_comments" value="y">

```

# Answer
> 2 votes
You write:

> The URL contains the entry\_id @ segment\_3

But

The return url has "success" as segment\_3.

```
<input type="hidden" name="return" value="dir/dir2/success/15771">

```

This is not a valid entry.

You can either change

```
 {exp:safecracker channel='xy' … entry_id='{segment_3}'}

```

to

```
 {exp:safecracker channel='xy' … entry_id='{segment_4}'}

```

Or change the url return path to something like

```
<input type="hidden" name="return" value="dir/dir2/15771/success">

```

# Answer
> 0 votes
Are you passing the entry id as ENTRY\_ID in the return?

```
{exp:safecracker channel="channel_name" return="channel_name/edit/ENTRY_ID" entry_id="{segment_3}"}

```

---
Tags: safecracker, error
---


title: Safe Harbor not saving settings

text:
# Question
Title: Safe Harbor not saving settings
I get this message in the CP trying to set Safe Harbor settings: Failed to save settings on http://eeharbor.com. Make sure your website is publicly accessible.

The site is publicly accessible and passes the Safe Harbor compatibility check.

# Answer
This can happen for several different reasons (allowed URI characters, CURL support not being present, PHP safe\_mode, errors being thrown in the ExpressionEngine install, etc..). I would recommend opening a support request with http://EEHarbor.com
> 4 votes

---
Tags: backup
---


# Question
Title: Shopping cart with diff. product pricing & renewal?
What EE shopping cart/e-commerce plugin that can do the following:

1. sell digital product, using PayPal or Skrill processors
2. different pricing schemes for a single product
3. one-time payment; purchase expiration; and an optional renewal

**Example:** I have a digital item to sell, named **XYZ**.

1. I want to sell **ZYC** for different pricing schemes & expiration:
    * ***XYC Lite*** for $50 & will expire in 6 months; $10 for renewal (not recurring but only an option)
    * ***XYC Pro*** for $100 & will expire in 1 year; $20 for renewal (not recurring but only an option)
    * other pricing schemes....
2. I must be able to set whether purchases of **XYC** is **auto-approve** or **manually approve**.
    * ***Auto-approve*** \- after a user made the payment, it's already considered a "**successful purchase**" (*see #3 below*) and can immediately access the download.
    * ***Manually approve*** \- after a user made the payment, it will be considered as "pending" and not yet successful. An admin must manually approve for it to become a "**successful purchase**" (*see #3 below*).
3. Successful purchase of the item will move the user to a certain Member Group:
    * ***XYC Lite*** purchasers will be moved to **Lite Group** member group.
    * ***XYC Pro*** purchasers will be moved to **Pro Group** member group.
4. In the "Purchase Area" (*displays purchases*) of the user, they have an option to renew even if it's not yet expired. Renewing will extend the timeframe of the expiration.
5. When an item purchased is nearly expiring, it must send an email reminding about it, i.e. "you need to renew".
6. Upon expiration of purchase, the user will be move back to a specified member group and can no longer access the download. He must have an option to renew as the price indicated in #1 but take note that the renewal is not a recurring payment, it's just an option.
7. Renewals (for example **XYC Lite**; $10) should be auto-approve (*regardless if I set the item purchase to manual approve*) and will again move the user to the specified member group and give him another 6 months access to download.

# Answer
> 1 votes
None of them will do all of that out the box.

@Jason-Mayo is correct in that Cartthrob is your best bet as it's the most flexible out the lot, and so is the one you should choose. However, @Ramil-Alcibar is also correct as it can't be done without custom coding. For example, your being able to set a product to be auto approve or manual approve, you would need to create a EE extension type add-on that, when the order confirmation comes back from the payment provider, will check the product that has been bought, see if it is auto or manual approve and then set the status of said order accordingly. Not actually that difficult to do if you know how to code.

There are plenty of excellent EE devs around that can help you with this!

# Answer
> 0 votes
I would go for Cart Throb (http://cartthrob.com) as that will pretty much do all this.

Remember, EE is quite durable in the way that a lot of the features are built in i.e. Member Groups etc.

I've run Cart Throb on a few eCommerce sites, all with different needs (Some with the need for different prices, per member group) and it's always worked out in the end. With no hacking and no PHP.

---
Tags: ecommerce, shopping-cart, recommendation-request
---


# Question
Title: expresso Store: Inventory not showing in cp for client's member group
I created a member group for the client, with this two options: \- Can access ADD-ONS: Modules \> yes \- Can access module: Store \> yes

When i access with the client profile , i can see the "store" tab, but "Inventory" is not present

why? Thanks in advance

# Answer
> 1 votes
Access to the Inventory page/menu item is controlled by your client's access to your products channel(s).

Double check in your member group settings, under "Channel Assignment", that your client's member group has the privilege "Can post and edit entries in: Products" (or whatever your products channel is called).

If more than one channel has a Store Product Details fieldtype, your client's member group must have access to **all** these channels.

---
Tags: expresso-store
---


title: Entry with umlauts will not save

text:
# Question
Title: Entry with umlauts will not save
I have an odd problem: Entries wth german umlauts (ä ö ü), in the the title oder anywhere else, will not save. Instead the field will clear and the page will reload. There is no JS validation going on.

My problem is pretty much the same as described here: http://ellislab.com/forums/viewthread/196640/#925586 though i can not fix it just by using php 5.2.x (I run 5.2.14)

Extension wise i run navee, wygwam, matrix and multi language support by biber ltd.

Umlauts in the wygwam-field are possible if I use the option to encode them to entities.

As for the database this strikes me a bit odd... but I am not the server-admin and can not test around easily.

```
collation_connection:   utf8_general_ci
collation_database: utf8_unicode_ci
collation_server:   latin1_swedish_ci

```

Thanks in advance, guys.

# Answer
> 2 votes
Hmm, odd one, i would have to say that the collation\_server being latin 1 would be at fault. Collation specifically is responsible for comparing and sorting in mysql. So, i'm guessing in the saving of the entry, it's trying to compare data, that is: one being utf-8 once it's in the db, and one that is latin1 before it gets to the db. This would cause a fatal mysql error and prevent any further inserts or whatever. You're going to have to get that server collation changed i would say.

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


title: Creating a read more link for blog.

text:
# Question
Title: Creating a read more link for blog.
I am working on a site that has a main entry but as I post new entries, it pushes existing content down into summarized items the user can click on for more. I want to have a little summary so the user can read a quick outline of what is being discussed or viewed without having to click on it. I would like to have the typical "Read More" link, however I am not exactly sure how to set that up or code it.

I came across this article while I was searching for possible solutions.

http://colly.com/comments/more-more-more-links-in-expression-engine/

However, I see that it was posted in 2006 so I was curious if this was what I was looking for and secondly if this is still the method used today. I currently have my entries set up with a title, a vimeo link and also a text entry about what the video is going to cover. Thanks for any help, as always it is greatly appreciated.

# Answer
> 6 votes
You have two primary options here.

The first, which I'd recommend, is to have a dedicated "Summary" field in your channel. This way the summary can be specifically-crafted as a *summary*, which is far more useful to your readers, rather than just whatever the first X-number of words of your entry happens to be. Then, display it with a link to your full entry:

```
{exp:channel:entries channel="blog" limit="10"}
    <h2><a href="{title_permalink="blog/entry"}">{title}</a></h2>
    {blog_summary}
    <p><a href="{title_permalink="blog/entry"}">Read more ...</a></p>
{/exp:channel:entries}

```

(Where **blog/entry** is your single entry template, in which you display all your fields for a single entry.)

Your other, lazier option is to use a plugin on your content field, like Hacksaw, which truncates your content into a summary:

```
{exp:channel:entries channel="blog" limit="10"}
    <h2><a href="{title_permalink="blog/entry"}">{title}</a></h2>
    {exp:eehive_hacksaw words="50" append="..."}
        {blog_content}
    {/exp:eehive_hacksaw}
    <p><a href="{title_permalink="blog/entry"}">Read more ...</a></p>
{/exp:channel:entries}

```

Either one will get the job done for you.

---
Tags: ee2, entries, vimeo
---


# Question
Title: Disable database-templates within ExpressionEngine 2
I'm working on EE2 theme and I can't find solution how to force EE use templates directly from the file system.

Generally I want to disable database templates while I'm working on theme, to get development quickly.

Is it possible? Thanks

# Answer
That would be the save templates as files feature. Once you've configured a template path you can save individual templates as files or you can sync all of your templates to file via the Templates \> Synchronize Templates page.

Once you've done that any changes you make to the template files will take effect immediately, without you needing to manually sync them to the DB.
> 7 votes

# Answer
I would recommend setting the save template as text files (as suggested by Dom) option in you config file. There is a good tutorial about putting your config file to better use here.

In a nutshell though it's this:

```
$config['save_tmpl_files'] = "y";
$config['tmpl_file_basepath'] = "/path/to/your/templates/";

```
> 3 votes

---
Tags: templates, config
---


# Question
Title: How to make a playa field required in a safecracker form?
How do I make a Playa select field required in my Safecracker rules?

I have a playa field in my safecracker form as follows. The field generally works fine, but I cannot get Safecracker to require it. I've tried rules:training\_teams="required".

```
<select id="training_teams" name="training_teams[selections][]">
    <option value="">Select Race</option>
    {embed="includes/_training_teams" selected="{training_teams:child_ids}"}
</select>

```

The embed file is as follows:

```
{exp:channel:entries dynamic="no" status="open" channel="rally_athlete_program"
    orderby="title" sort="asc" date_field="event_date"
date_field_start="{current_time format='%Y-%m-%d'} 12:01 AM"}
    <option value="{entry_id}">{if entry_id == embed:selected}selected{/if}{title}</option>
{/exp:channel:entries}

```

# Answer
Playa has respected EE’s “Is this a required field?” field setting since version 4.0.5. Simply set that setting to “Yes” and save your field.
> 2 votes

---
Tags: add-on, safecracker, playa
---


title: Use Matrix Column Labels in Templates?

text:
# Question
Title: Use Matrix Column Labels in Templates?
I'm curious if anyone has used Matrix Column Labels in their templates before?

SCENARIO:

I have tabular data showing table headers: ROOM #, ROOM NAME, etc...

Those double as my Matrix Column Labels. Instead of having:

```
<tr>
        <th width="101">Room #</th>
        <th width="223">Room Name</th>
</tr>

```

I'd rather have something like:

```
{MATRIX_FIELD}<tr>
            <th width="101">{column_number}</th>
            <th width="223">{column_name}</th>
</tr>{/MATRIX_FIELD}

```

---

I didn't see anything in the Matrix documentation to pull the column labels and was curious if anyone has done this before. Obviously I can pull in the COLUMN NAME but nothing for LABELS.

Thanks everyone!

# Answer
> 3 votes
I don't know of a way to get the labels in the traditional Matrix tag pair, but Matrix does have the {your\_matrix\_field:table} tag, which prints out a full HTML table. I believe this table uses your column names as the table headers. This might not give you the granular control over the markup that you need, but maybe it'll be good enough?

# Answer
> 1 votes
In addition to everything the others have noted...

I have used JS to create custom UI's for Matrix fields, even breaking Matrix out of a table into separate div's. A very simple solution would be to use JS to override the data you don't want.

---
Tags: matrix
---


# Question
Title: Pagination issue with Query and Conditional Statement
I have a script that uses query to determine if a particular entry is open or closed. based on that entry, it then displays a list of blog entry excerpts. if that particular entry id has a status of closed, it displays the list with one category hidden. Otherwise it shows all categories.

Everything on this works fine except for the pagination. I cannot get it to appear inside the conditional, and when it is outside of the conditional, it just shows the same few blog excerpts on every page.

Below is my code:

```
{exp:query sql="SELECT status FROM exp_channel_titles WHERE entry_id = '46'"}
            {if status == 'closed'}
                {exp:channel:entries channel="blog" disable="member_data" limit="3" paginate="bottom" order_by="desc" category="not 4"}
                    {if no_results}
                        <p>No results available</p>
                    {/if}
                    <div class="entry"><article>
                        <div class="header"><header>
                            <hgroup>
                                <h2 class="category">{categories}{category_name}{/categories}</h2>
                                <h1>{title}</h1>
                            </hgroup>
                            <p><span class="date">{entry_date format="%F %d, %Y"}</span> / <span class="author">{author}</span></p>
                        </header></div> <!-- /.header -->
                        {if blog_image}
                            <p><img src="{blog_image}" alt="{title}"></p>
                        {/if}
                        {blog_excerpt}
                        <a href="{url_title_path='blog/entry'}" class="more">read more ></a></p>
                    </article></div> <!-- /.entry -->

                    <div class="moreEntries">
                        {paginate}
                            {if previous_page}
                                <a href="{auto_path}" class="prev"><  Newer Posts</a>    |
                            {/if}
                            {if next_page}
                                <a href="{auto_path}" class="next">Older Posts  ></a>
                            {/if}
                        {/paginate}
                    </div> <!-- /.moreEntries -->
                {/exp:channel:entries}
            {if:else}
                {exp:channel:entries channel="blog" disable="member_data" limit="3" paginate="bottom" order_by="desc"}
                    {if no_results}
                        <p>No results available</p>
                    {/if}
                    <div class="entry"><article>
                        <div class="header"><header>
                            <hgroup>
                                <h2 class="category">{categories}{category_name}{/categories}</h2>
                                <h1>{title}</h1>
                            </hgroup>
                            <p><span class="date">{entry_date format="%F %d, %Y"}</span> / <span class="author">{author}</span></p>
                        </header></div> <!-- /.header -->
                        {if blog_image}
                            <p><img src="{blog_image}" alt="{title}"></p>
                        {/if}
                        {if event_location}
                            <p><strong>{event_location}</strong><br>
                            {blog_month} {blog_day}, {blog_year} - {blog_event_time}}</p>
                        {/if}
                        {blog_excerpt}
                        <a href="{url_title_path='blog/entry'}" class="more">read more ></a></p>
                    </article></div> <!-- /.entry -->

                    <div class="moreEntries">
                    {paginate}
                            {if previous_page}
                                <a href="{auto_path}" class="prev"><  Newer Posts</a>    |
                            {/if}
                            {if next_page}
                                <a href="{auto_path}" class="next">Older Posts  ></a>
                            {/if}
                        {/paginate}
                    </div> <!-- /.moreEntries -->
                {/exp:channel:entries}
            {/if}
        {/exp:query}

```

Thanks for any help you can offer!

# Answer
You're running into variable collision. Since both the Query and Channel modules use the `{paginate}` tags, the outer-most module (Query) is winning the battle.

The solution is to embed your Channel Entries loops.

```
{exp:query sql="SELECT status FROM exp_channel_titles WHERE entry_id = '46'"}
    {if status == 'closed'}
        {embed="_embeds/loop1"}
    {if:else}
        {embed="_embeds/_loop2"}
    {/if}
{/exp:query}

```

Then your two chunks of code go into templates located at **\_embeds/loop1** and **\_embeds/loop2** respectively (use your own naming conventions of course).

I should also point out:

* `order_by="desc"` does nothing. You're probably thinking of `orderby`, but that parameter accepts a field name, not a sort order ... what I think you want is `sort="desc"`, which you can omit anyway, because that is the default sort. :)
* `<div class="moreEntries">` should be *within* your `{paginate}` loop, otherwise you'll end up with `<div class="moreEntries"></div>` at the end of every entry in the loop, followed by your pagination links outside of the final `moreEntries` division.
> 2 votes

---
Tags: pagination, query
---


# Question
Title: What are my best options for powerful member management with many custom fields?
Working on a college site that will have many, many members (in the hundreds), only a fraction of which will actually be editors in the CMS. All members need to have access to their own information (so they can update with ease). Each member will have a ton of custom fields, too, including specialty fields like Matrix and Playa (which, as I understand it, isn't allowed with the built-in member management).

What are my options here? Really appreciate any suggestions I can get.

# Answer
> 7 votes
There are a number of member add-ons that substitute the native member module for channel entries.

They are:

Since members are handled as regular channel entries, you are free to use any custom fieldtype.

Also, since they are channel entries, you can use Safecracker to allow the users to edit their own profiles/entries.

As Erik mentioned, Focus Lab wrote up a comparison of the big 3 membership addons mentioned above.

# Answer
> 1 votes
I think almost any of the 'member data' in channels add-ons will work for you. Which one would be best, would require more information on what you hope to do with members, besides let them create detailed profiles.

All the 'member data' in channels add-ons, still use EE's Membership Module to manage permissions, and it can easily handle hundreds of records. We've got a couple of clients with more than 45,000 members, and the Membership Module handles it fine. One ONLY uses the Membership Module, the other uses Zoo Visitor.

The membership management field is pretty long, just take a look at Devot-ee, but if you want to start exploring, I'd look at these items: Safecracker Registration, Zoo Visitor, and Profile:Edit.

They offer similar flexibility in terms of being able to handle anything you can throw at channel data, but depending on what else you want to accomplish one maybe better than the other for you.

# Answer
> 0 votes
an option could be visitor, you can use matrix and playa (or other fieldtypes) there http://ee-zoo.com/add-ons/visitor/

---
Tags: members, custom-fields, member-details
---


# Question
Title: How to share direct links to file uploads that always show the latest version of a file
I have a fairly large site that is using Safecracker File for quite a few fields. Some of the entries have files that get updated each month. The issue is that "removing" a file from an entry does not delete and replace the file on the server so if you are trying to attach a file with the same filename as the file already uploaded, the new file will get renamed by EE on upload.

That's usually not a problem, but the client has a case where they do not want the filename to change because they want to share a direct link to the file with their team - and they don't want to have to reshare the link each time the entry is updated.

For example, this month they share a link to "Marketing-Presentation.ppt" file

```
example.com/uploads/docs/Marketing-Presentation.ppt

```

Then next month when it's updated, the client uploads the new file... but the new file has a 1 appended to the filename... so the new link is the one below but the link shared last month no longer links to the latest version of the file.

```
example.com/uploads/docs/Marketing-Presentation-1.ppt

```

Here's what I'm thinking so far...

* Is there a file fieldtype that will delete and replace the existing file rather than just upload and rename?
* Perhaps the best way to solve this is to give the client another way to share direct download links that do not contain the file name.

I'd like to hear your insights on either of those approaches or something else I'm not thinking about.

# Answer
> 4 votes
Instead of sharing the url to the file itself, share the url to an entry which provides a download link to the file "attached" to it.

The site admins would upload/attach the file to an entry. If the file needed updating they would edit the existing entry and upload a new file. The name of the file wouldn't matter as that would not be shared. The url to the entry would never change.

On your front-end the template could either show a download link or automatically trigger a download of the file attached to the entry.

# Answer
> 0 votes
While it's still brand new and bound to have some issues, which you can probably track here, it does sound like Assets v 2.0 will allow you to do this.

See sections on Conflict Resolution and Lossless File Replacement from the new Pixel and Tonic blog post, but quoted here for easy reading:

> **Conflict Resolution** When you upload a file with the same name as an existing file, Assets now lets you chose how to proceed. You can rename the new file, replace the original file, or cancel the upload. We didn’t stop at file uploads: you’re given similar choices any time you perform any action which would result in two files or folders with the same name living in the same directory.

followed by

> **Lossless File Replacement** You can now replace existing files while preserving the original file’s metadata and entry associations. Simply upload a new file with the same name as the original. When you’re asked how you want to handle the naming conflict, choose to replace the original file, and presto: new file, same old metadata.

I think those two options, would easily allow the replacement of the file and still maintain any data associated with it.

---
Tags: file-uploads, assets, safecracker-file
---


# Question
Title: Static page with no channel attached...can I assign a fake channel?
I have a static page that I don't have a specific channel for. Its just a contact form, and I don't see any reason to have it be a channel entry because there's not really content there to change or update. However, I have breadcrumbs and I use the code below to tell the breadcrumbs what to display, and given that there is no channel entry for my contact form, the breadcrumb shows up as blank. Is there a way to just assign a fake channel name to the contact page so that this code will work, or do I have to make a channel for it? or is there some other work around?

```
{if segment_2 != ""}
     <li class="breadcrumb"><p><a href="{path={segment_1}}">{channel}</a></p></li>
     <li class="breadcrumb"><p>{title}</p></li>
{if:elseif segment_2 == ""}
     <li class="breadcrumb"><p>{channel}</p></li>
{/if}

```

# Answer
> 2 votes
Typically when I want to only show certain snippets of code when I know the URL is fixed, I hard code the segment value in. So in your case I would just change your advanced conditional to:

```
{if segment_2 != ""}
 <li class="breadcrumb"><p><a href="{path={segment_1}}">{channel}</a></p></li>
 <li class="breadcrumb"><p>{title}</p></li>
{if:elseif segment_1 == "contact-us"}
 <li class="breadcrumb"><p>Contact</p></li>
{if:else}
 <li class="breadcrumb"><p>{channel}</p></li>
{/if}

```

---
Tags: channel, conditionals
---


# Question
Title: Adding Channel Field data inside safecracker_submit_entry_start callback function
I have Channel with fields A,B,C,D,E

I have a Safecracker form that contains input elements for channel fields A,B,C

I have an extension with the callback method

```
public function foo($safecracker_object)
{
  ...
}

```

which has the hook

```
safecracker_submit_entry_start

```

Given these data, what I want to do inside the callback function is to add channel fields D and E data manually so that in the end, what is being sent are the fields A,B,C,D,E.

Is there something in the safecracker object that enables me to add those data? I have tried using

```
public function form_hidden($name, $value = '')

```

and

```
public function form_attribute($name, $value = '')

```

in safecracker object and it did not work.

# Answer
I've very little experience with Safecracker but can you not simply manipulate the `$_POST` elements? The hook is called before any entry data is processed so I can't see why that wouldn't work.

```
public function safecracker_submit_entry_start()
{
    $_POST['news_body'] = 'Test';
}

```
> 2 votes

# Answer
The nice thing about safecracker is that modifying channel entries will actually trigger the channel module hooks :)

One of them might be of more use?

http://ellislab.com/expressionengine/user-guide/development/extension\_hooks/api/channel\_entries/
> 0 votes

---
Tags: safecracker, forms
---


title: structure module and classic subdomains

text:
# Question
Title: structure module and classic subdomains
We have a site originally written in ee 1.5.2 using the classic subdomain method. Can I take "classic" subdomain folders and move them into subfolders in Structure for organizational purposes and then use .htaccess to get them to show as subdomains in the browser when they are rendered?

Thank you in advance. . . to the remarkable ee se braintrust!

# Answer
I understand your thinking but I can't see it working.

As Travis says, the parent entries (for example /about) there's no way you could create a subfolder on the server of /about - as soon as you do that, it'll take precedence.

As for the htaccess route, the browser will try route it to an actual subdomain and would fail if not found.
> 2 votes

---
Tags: structure, htaccess, subdomain
---


# Question
Title: How to filter relationship field options?
Assume two channels: Channel A and Channel B.

Say that Channel A has a relationship field type that points to Channel B. When a Member is making an entry in Channel A, is there any way to limit the relationship field's options to display only the current Member's entries in Channel B?

Right now, I am seeing ALL of Channel B's entries regardless of which Member made the entry.

# Answer
> 5 votes
Not with the native relationship field but you can with Playa.

# Answer
> 1 votes
This will probably be too late but it is possible to do that natively.

Allow PHP on the template and set it to input on the template preferences. Then add the following query in your template. Replace 'your relationship field' with the name of your relationship field and change the channel id number to the id of the channel the entry is related to.

This will list all of the members entries from the related channel.

```
<select name="your_relationship_field" id="your_relationship_field">

{exp:query sql="SELECT entry_id AS rel_entry_id, title AS rel_title, (SELECT rel_child_id FROM exp_relationships WHERE rel_id = '{your_relationship_field}' LIMIT 1) AS rel_child_id FROM exp_channel_titles WHERE channel_id =1 AND author_id = <?php echo $this->EE->session->userdata('member_id'); ?>"}
        <option value="{rel_entry_id}"{if rel_child_id == rel_entry_id} selected="selected"{/if}>{rel_title}</option>

{/exp:query}
</select>

```

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


title: Numbers cannot be used as URL Titles?

text:
# Question
Title: Numbers cannot be used as URL Titles?
In 7 years with ExpressionEngine I've never seen this error before when saving a channel entry: Numbers cannot be used as URL Titles

And, there are past existing entries in this site with numbers as URL Titles. Anyone know what might be causing this and if there is a switch to allow them? I can't find anything.

# Answer
> 7 votes
This is a feature of ExpressionEngine. You won't be able to use numbers alone as URL Titles. If you managed it in the past, it was probably a bug/fluke that it was allowed, or the entry was created in a non-standard way.

In the `content_edit.php` file there's a check for `is_numeric()` that triggers an error.

```
// Is the url_title a pure number?  If so we show an error.
if (is_numeric($data['url_title']))
{
    $error[] = lang('url_title_is_numeric');
}

```

It's probably in the forums in a few spots, but here's one I found straight from the horse's mouth (though it's just stated as fact, not explained): http://ellislab.com/forums/viewthread/99496/#502754

**Edit** Looks like Lisa beat me too it.

# Answer
> 4 votes
That's odd, you've always had to use an alpha character - not numbers only. EE would interpret those as IDs rather than URL titles and become very confused. I'm not sure how you'd have number-only URL titles if submitting directly through EE's forms.

# Answer
> 0 votes
As a workaround you could use the entry\_id of the entry as a segment in your page's url. I often do this and have the entry\_id as the last segment. You can then use the {last\_segment} tag in your channel entries tag in the entry\_id parameter.

---
Tags: url-title
---


# Question
Title: Channel Entries - Skip a particular channel entry
Okay, I've got a page with a url that has the channel entry title in the URL. At the beginning of the page, I show the single article for that entry, but then underneath the article, I need to show all the other articles. So I can do this by setting dynamic="no" which reverts it to a normal channel:entries loop, but I would like this loop to skip and ignore the entry that is showing ta the top of the page.

I do not know how other to do this, but I put a if statement in my channel entries loop, but the problem is, I'm using switch to setup div's for a new row every third entry and the if statement messes with that.

I need the channel entries to ignore a particular entry, or I need a way to do a "continue" for the loop without messing with the switch count.

Here's my current code:

```
{if last_segment}
    {exp:channel:entries channel="event" orderby="date" sort="desc" status="open" category="10" dynamic="no" limit="7"}
        {if url_title != last_segment}
{switch="<div class='eventsRow'>||"}
    <div id="{url_title}" class="event {switch="|| lastEvent"}" data-count="{count}">
        <div class="pastEventConent">
            <h4>{title}</h4>
            <p>{excerpt}</p>
            <div class="copy">
                {copybox1}
            </div>
            <a data-tag="{url_title}" href="{title_permalink='events'}">View >></a>
        </div>
    </div>
{switch="||</div>"}
        {/if}
    {/exp:channel:entries}
{if:else}
    {exp:channel:entries channel="event" orderby="date" sort="desc" status="open" category="10" offset="1" dynamic="no" limit="6"}
{switch="<div class='eventsRow'>||"}
    <div id="{url_title}" class="event {switch="|| lastEvent"}" data-count="{count}">
        <div class="pastEventConent">
            <h4>{title}</h4>
            <p>{excerpt}</p>
            <div class="copy">
                {copybox1}
            </div>
            <a data-tag="{url_title}" href="{title_permalink='events'}">View >></a>
        </div>
    </div>
{switch="||</div>"}
    {/exp:channel:entries}
{/if}

```

Any help appreciated :)

# Answer
> 7 votes
Much simpler than you think! Just add `url_title="not '{segment_3}'"` to your Channel Entries tag. (Or whichever segment holds your entry's `url_title`.)

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


# Question
Title: Default to no styling images in EE's Rich Text Editor
Is there a way to disable the Rich Text Editor from adding styling to images that are inserted into the field? I am specifically referring to use of the RTE in the administration portal.

For example if I add an image it automatically has:

```
<figure style="text-align: center;"><img alt="" src="http://www.domain.com/uploads/assets/743280d7.hero2.jpg"></figure>

```

Is there a way to have it default to just showing:

```
<img alt="" src="http://www.domain.com/uploads/assets/743280d7.hero2.jpg">

```

Thanks!

# Answer
> 2 votes
This happens in /system/expressionengine/rte\_tools/image/rte.image.js around line 75

```
var $img = $('<figure/>')
                .css('text-align','center')
                .append(
                    $('<img alt=""/>')
                    .attr('src', image_object.thumb.replace(/_thumbs\//, ''))
                );

```

It would appear the image is being wrapped in a `<figure>` tag to allow for alignment (left, right) and to add a caption, if present, in a nested `<figcaption>` tag.

Probably only way to avoid this is to edit the script.

---
Tags: image, richtext, formatting
---


# Question
Title: How/where do I place commonly used functions across multiple plugins?
I have 2 or 3 custom plugins that I'm using on a project. In each file I have a number of 'helper' functions (is this the correct terminology?) that perform a task that might be required in a few of the functions within each plugin.

At the moment I have a copy of each helper function in each of the plugins. The code is the same and I realise this isn't the right way to go. My question is, where to put them and how to reference them from within each of these custom plugins?

Thanks in advance!

Jim

# Answer
I would suggest bundling all of your custom functionality for the project into one add-on (more on this thinking) - then you can use EE's helper implementation for this. (Have a look at the recommended add-on directory structure.)

In your add-on package, add a **helpers** directory, and in it place one or more PHP files which contain your function(s). Be sure that they are all named with a **\_helper.php** suffix.

```
my_addon
    helpers
        my_functions_helper.php
    mod.my_addon.php
    pi.my_addon.php
    (etc)

```

Then in your plugin or module:

```
$this->EE->load->helper('my_functions');
// you can now use all of the functions contained in my_functions_helper.php

```

But, if you want to stick with multiple add-ons, you can certainly include any shared file that lives inside your **third\_party** directory:

```
include(PATH_THIRD.'/my_addon/libraries/my_library.php');

```

(The location and file naming after `PATH_THIRD` is up to you.)
> 5 votes

# Answer
It seems like you'll want to use a separate directory in the `system/expressionengine/third_party/` hierarchy just for your library.

So if your plugins are plug1 and plug2, they'll normally live in `system/expressionengine/third_part/plug1/pi.plug1.php` and `system/expressionengine/third_party/plug2/pi.plug2.php`. For a common library referenced in both plugins, just put it somewhere like `system/expressionengine/third_party/plugs/pluglib.php`.
> 2 votes

---
Tags: add-on-development, plugin
---


# Question
Title: Using a related entry inside a reverse related entry?
I have a channel 'user' with a detail page about them.

I then use a

`{reverse_related_entries channel="post"}` tag to pull in entries that user created and list them on that page. This all works great.

The entry in the post channel also has a related entry, so I am trying to call it but am not having any luck. Can I call a related entry inside a reverse related entry?

Heres an example with just EE tags:

```
{exp:channel:entries channel="user"}
    {title}
    {reverse_related_entries channel="posts"}
        {title}
        {related_entries id="myfield"}
            {title}
        {/related_entries}
    {/reverse_related_entries}
{/exp:channel:entries}

```

but the nested related entry returns `{REL[myfield]UyOu51DdREL}`.

Any idea how I can get this to work?

Thanks!

# Answer
> 2 votes
This can be done natively using an embedded template.

```
{exp:channel:entries channel="user"}
    {title}
    {reverse_related_entries channel="posts"}
        {embed="_embeds/related" entry_id="{entry_id}"}
    {/reverse_related_entries}
{/exp:channel:entries}

```

Then in your embed (**\_embeds/related**):

```
{exp:channel:entries channel="my_channel" entry_id="{embed:entry_id}" dynamic="no"}
    {title}
    {related_entries id="myfield"}{title}{/related_entries}
{/exp:channel:entries}

```

# Answer
> 1 votes
Don't think you can do it natively but you can using the third party add-on Playa and the `var_prefix` option.

```
{exp:channel:entries channel="user"}
    {title}
    {exp:playa:children channel="posts" parse="inward" var_prefix="post"}
        {exp:playa:children channel="editors" var_prefix="editor"}
            {post:title} - {editor:title}
        {/exp:playa:children}
    {/exp:playa:children}
{/exp:channel:entries}

```

You would replace `channel="editors"` with the name of the related channel and set a `var_prefix` name that suited.

---
Tags: related-entries, reverse-related-entries
---


# Question
Title: Autofill relationship field with no user input required
I have a channel called projects and a channel called project\_update.

I'm using a reverse relationship to link project updates to a project. This allows the user to post a project update to a specific project.

The project page has a safecracker form at the bottom to allow them to post a project update to that project.

The problem I have is currently the user needs to select from a dropdown list which project he wants to post the update to. Instead of giving him the option I need it to look at the project he's currently in and automatically fill the relationship field with this project.

I heard that Playa has an autocomplete features but this looks like a search box that autocompletes as you type. This is no good to me.

Was wondering if anybody has any solutions to this.

This is the code I currently have, it lists all the projects owned by the member but I need it to list only the current project.

```
 {exp:safecracker channel="project_update" include_jquery="no" return="projects"}
<p>
 <label>Update the following Project</label>
<select name="relationshiplink" id="relationshiplink">
{exp:query sql="SELECT entry_id AS rel_entry_id, title AS rel_title, (SELECT rel_child_id FROM exp_relationships WHERE rel_id = '{relationshiplink}' LIMIT 1) AS rel_child_id FROM exp_channel_titles WHERE channel_id =1 AND author_id = <?php echo $this->EE->session->userdata('member_id'); ?>"}
        <option value="{rel_entry_id}"{if rel_child_id == rel_entry_id} selected="selected"{/if}>{rel_title}</option>
{/exp:query}
</select>
</p>
  {/exp:safecracker}

```

# Answer
Since your project area is determined by the URL, you can just query the URL to get the `entry_id` of your project, and add that to a hidden field:

```
{exp:query sql="SELECT entry_id AS project_entry_id FROM exp_channel_titles WHERE url_title = '{segment_3}' AND channel_id = 1"}
    <input type="hidden" name="update_project[selections][]" value="{project_entry_id}" />
{/exp:query}

```

You'll have to change/check three things here:

* the `channel_id` (it should be the ID of your Projects channel)
* the URL segment where your `url_title` lives (I have it as `segment_3` here)
* the short name of the Playa field in your Updates channel (I have it as `update_project` here).
> 4 votes

# Answer
if you already display the project itself above the form, then you can probably copy / pick-up the entry\_id (with stash or mx\_jumper) and insert/output it into a hidden field of the safecracker form.

Check out the normal relation dropdown html first, as to what the field name is and what form the value is in. You can assemble a input-hidden field accordingly.
> 1 votes

---
Tags: safecracker, relationships
---


title: Module I'm developing will not install

text:
# Question
Title: Module I'm developing will not install
I am new to EE development and am trying to get my head round creating a module. I've read various tutorials and docs and have a skeleton module created, but it will not install.

In the list of modules I can see the name and description of my module, but when I click "Install" nothing happens. The status is still "Not Installed".

I have checked the database and the modules table has an entry for my module, so the `install()` function is executing, but the status isn't changing.

Here is my upd file:

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

class Photo_pdf_upd {

    public $version = '1.0';

    private $EE;

    /**
     * Class Constructor
     */
    public function __construct() {
        $this->EE =& get_instance();
    }

    // -------------------------------------

    /**
     * Installation Method
     *
     * Required by ExpressionEngine
     *
     * @return boolean  TRUE
     */
    public function install() {
        // Drop info on the module into the modules table
        $mod_data = array(
            'module_name'           => 'Photo PDF',
            'module_version'        => $this->version,
            'has_cp_backend'        => 'n',
            'has_publish_fields'    => 'n'
        );

        $this->EE->db->insert('modules', $mod_data);

        return TRUE;
    }

    // --------------------------------------

    /**
     * Module Uninstaller
     *
     * Required by ExpressionEngine
     *
     * @return boolean  TRUE
     */
    public function uninstall() {
        $mod = $this->EE->db->select('module_id')->get_where('modules', array('module_name'=>'Photo PDF'))->row('module_id');

        $this->EE->db->where('module_id', $mod)->delete('module_member_groups');

        $this->EE->db->where('module_name', 'Photo PDF')->delete('modules');

        return TRUE;
    }

    // ---------------------------------------

    /**
     * Module Updater
     *
     * Required by ExpressionEngine
     *
     * @return boolean  TRUE
     */
    public function update($current = '') {
        // Nothing to do here
        return TRUE;
    }
}

/* End of File: upd.photo_pdf.php */

```

# Answer
> 6 votes
$mod\_data\['module\_name'\] should be class name of your actual module file (mod.photo\_pdf.php), in your case 'Photo\_pdf'

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


# Question
Title: How to redirect EE site to www. using htaccess & keep the index.php file removed
We are running an EE site which is successfully stripping the /index.php from the URL using the following rewrite rule:

RewriteCond $1 !^(docs|index.php|sitemap.php) \[NC\] RewriteRule ^(.\*)$ /index.php/$1 \[L\]

I now need to get the site to redirect from the non www (example.com) version to the www. (www.example.com) version of the site. At the moment I've tried:

```
RewriteCond $1 !^(docs|index\.php|sitemap\.php) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

```

This adds the 'www.', but puts the index.php back on all pages of the site. What am I doing wrong?

# Answer
Try changing the order of your RewriteRules. i. e. put the addition of the www before the removal of the index.php.
> 7 votes

# Answer
This is the .htaccess we use for clients who request the www.:

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

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
RewriteCond %{HTTP_HOST} (.+)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

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

```
> 2 votes

---
Tags: ee2, htaccess
---


# Question
Title: Password Protect Development Environment Only?
I'm developing a site with Git and Master Config, and up until yesterday I was forcing users to log-in to view the site on the development server with this code in my document head template:

```
{if logged_out}
    {redirect='tmp/login'}
{/if}

```

But now the site has been launched to production, I have to remove that code and template group. But since everything is synced up using Git, the development environment won't be password protected either.

I'd prefer to use EE's built-in login system over say a .htpasswd file if possible. I figure I can .gitignore the `tmp` template group so it only exists on development. Is there a Master Config variable I can use to only parse the `logged_out` conditional in the development environment? Like:

```
{if ENV == 'dev'}
    {if logged_out}
       {redirect='tmp/login'}
    {/if}
{/if}

```

# Answer
> 5 votes
Version 1.1.1 of the Master Config added two global variables by default. Here's a sample of use:

```
{if global:env == 'dev'}
    {if logged_out}
        {redirect='tmp/login'}
    {/if}
{/if}

```

An alternate approach without nesting conditionals:

```
{if global:env == 'dev' && logged_out}
    {redirect='tmp/login'}
{/if}

```

If you are using a version before 1.1.1 you can just add that section of code to your current `config.master.php` file.

> I figure I can .gitignore the `tmp` template group so it only exists on development.

I'd recommend adding a conditional to any template in that group. The conditional would redirect the user if they aren't in the desired environment. It's a bigger process depending on how many templates you're running in the group, but allows you to track the template(s) and their changes. It also means your other contributors will have these files.

Example:

```
 {if global:env != 'dev'}{redirect='/'}{/if}

```

# Answer
> 3 votes
Jason Siffring at Surprise Highway posted an article on how to do this with .htaccess. Unfortunately it requires a .htpasswd file, which it looks like you're trying to avoid.

Here's the link in case it's useful: http://surprisehighway.com/article/how-to-password-protect-development-and-staging-sites-with-htaccess

# Answer
> 2 votes
The main **Master Config file** has global variables configured that you can use:

From line 253:

```
$master_global = array(
    'global:env' => ENV,
    'global:env_full' => ENV_FULL
);

```

The variables for each environment are set in the **config.env.php file**.

`{global:env}` will get you **"prod, stage, dev or local"** and `{global:env_full}` will get you **"Production, Staging, Development or Local"**.

These are global variables you can access in your templates.

So this conditional will get you what you need:

```
{if "{global:env}" != 'dev'}{redirect='/'}{/if}

```

---

I'd set a global variable in the config.php file:

```
$assign_to_config['global_vars']['ENV'] == 'dev';

```

Then use this in your template:

```
{if "{ENV}" == 'dev'}

```

# Answer
> 2 votes
I would suggest putting site offline (via EE preferences or config file) during development and using Smart Switch to allow limited access

# Answer
> 1 votes
What about using EE's built-in template permissions? It's located under the "access" tab when editing a template. Way easier IMHO than writing a bunch of conditionals into your templates and then having to rip them out when going live. Here's an example:

I would link to the page in EllisLab's docs, but the EE docs are down right now.

---
Tags: git, security, focus-lab-master-config
---


# Question
Title: Can I still purchase additional site licenses for EE 1.x MSM
I have a client site running on a legacy version of EE1.x, it's pretty old and they have no desire to upgrade to EE 2.x as it does the job just fine as is.

They have a MSM license associated with the site and as such can run up to 3 sites off the one install - at present they are running 3 sites but wish to add another.

This is a simple job, very much a copy/paste on the existing sites to create a new one for a slightly different target audience - however I'm not sure if I can even buy a new EE1.x MSM site license - the EE store does not appear to be happy with me trying to do so...

Does anyone know if Ellis Lab are still selling EE1.x MSM site licenses?

# Answer
> 1 votes
Yes. Just email them at sales@ellislab.com. It requires an "upgrade" of the MSM license I believe. Then you can add licenses. (But they can confirm or correct this information for you.)

For future reference (for anyone reading this): these types of questions are probably not well suited for StackExchange. Just shoot EllisLab an email so you can get an answer directly from the source. Both sales@ellislab.com and team@ellislab.com get to them I believe.

---
Tags: multi-site-manager, license, 1.x
---


# Question
Title: Basic conditionals not working after update
I just did some really really basic updates to my site, and now I'm having some extremely weird behavior. Take this conditional for example:

```
{if '{expiration_date format="%U"}' <= '{current_time format="%U"}'}

```

Despite outputting both these variables between comment-statements and actually seeing that expiration\_date is higher then current\_time (i.e. `1358865518 / 1358336648`) the result is still being output.

Now in another template I'm using MX Calculcator in a conditional to check for certain entry-counts (`{exp:mx_calc expression="mod(({count}-10),19)"}`), which was working just dandy til 5 minutes ago, and now always resolves....

Has anyone ever had this before? The only changes I've done are to templates...

# Answer
Ok, so apparently this is a pre `2.5.3` bug. Updating to `2.5.5` resolved this.
> 1 votes

---
Tags: conditionals, date, advanced-conditionals
---


title: Assets 2.0 update crashes CP & site

text:
# Question
Title: Assets 2.0 update crashes CP & site
More specifically, when opening the modules\>assets screen I get a whitescreen in both the site and the CP with the following:

```
Parse error: syntax error, unexpected T_STATIC in /home/ingedingen/domains/ingedingen.be/public_html/cmssystem/expressionengine/third_party/assets/helper.php on line 205

```

I've rolled back to assets1 in the mean time. This is on EE2.5.5. Any suggestions?

# Answer
> 5 votes
If you open system/expressionengine/third\_party/assets/helper.php and replace all occurrences of `static::` with `self::`, this error will go away. We'll have an official release with the fix shortly.

---
Tags: assets
---


title: Active Record: Show Tables

text:
# Question
Title: Active Record: Show Tables
Is there a codeigniter active record way of doing something like:

```
if(mysql_num_rows(mysql_query("SHOW TABLES LIKE exp_mytable"))==1)

```

I'm not seeing Show Tables as a method in the docs.

# Answer
> 4 votes
Neither Active Record nor DB Forge have a “SHOW TABLES” function. You’d have to just do it with `query()`:

```
if ($EE->db->query('SHOW TABLES LIKE `exp_mytable`')->num_rows())

```

---
Tags: add-on-development, module, codeigniter
---


# Question
Title: Using MSM & solspace user - members with same email address needed
i currently have several MSM sites in our EE install, our member database is synched (one way to us) with a partner with many thousands of members, which get access to one of our MSM sites, and are assigned automatically a member group.

We now find ourselves with some of the members of our partner that want some of our other services, **but there email address is already in our system** \- giving access to that member group, giving those individual members different groups are not an option. And ideally i done want to ask them to supply a different email address, for the second account.

As these particular members are created and approved in house, and not through registration. the best solution i can think of is to create a second account with a dummy email address, then modify the email address to their second account to their actual address, *so it will now be in the database twice.*

Is there potentially any issue with this?

If not is there anything we need to look out for?

Using EE v2.5.3

Thanks!

# Answer
Unfortunately unique email address is EE core requirement, you cannot override without modifying system files.

You may consider using some add-ons for advanced permissions management, such as Member Categories or MSM Member Group Switcher

Actually I think MSM Member Group Switcher might be the thing you're looking for, as it allows the user to be treated as part of one or another member group depending on what site he's logged in at.
> 3 votes

---
Tags: email, multi-site-manager, member-details, solspace-user
---


title: 500 error after site was hacked

text:
# Question
Title: 500 error after site was hacked
Website was hacked. After being cleaned up (but probably not 100% secured), all pages started returning a 500 internal server error. Host says it's not them. The server loads flat files perfectly. Moving /system/ returned "The system path does not appear to be set correctly. Please open your path.php file and correct the path" message, as expected. No idea what's causing the 500 errors. Probably related to the hack, but I can't be sure. Also don't know how to fix it. Any advice?

For context: I don't know if the site runs EE1 or 2. I'm a noob w/ EE. I was called in to help, but I don't know much about the site/server. I have FTP access but (as of now) no SSH access.

**Edit:** A local install of PhpMyAdmin is running on this server. I'm trying to convince the client to remove it. I've moved the PMA directory/files out of the web-accessible directory for now.

**Edit 2, more context:** This site runs on an IIS server. I can't make file-permission changes.

# Answer
With any software, it's good to contact the author if a security issue is suspected. If you have not already, contacting EllisLab support about this issue is a good idea.

This would prevent you from needing to post secure information about your site on a public network, and also enable EllisLab to see if EE was at fault, and if there is a security breach in the code that needs to be fixed to prevent it from happening again. EllisLab could help you examine likely targeted files to ensure the installation was cleaned up, and perhaps even coordinate with your host.

EllisLab Support Center & email contact info
> 5 votes

# Answer
Check the permissions on your index.php file.
> 1 votes

# Answer
Can you log into the backend?

If so you can find the information in the footer there. Also, if your login form looks like this then it is EE 2 http://d.pr/i/BvML

If you can't login or load any pages enable debugging to see the PHP errors that are popping up http://ellislab.com/expressionengine/user-guide/troubleshooting/general/blank\_pages.html

To enable debugging in an EE 1 site you can't log into, add the following to your system/config.php file:

```
$conf['debug'] = "2";

```

Use this if you can log into the backend:

```
$conf['debug'] = "1";

```
> 1 votes

# Answer
If it's telling you to open your path.php file, it sounds like an EE 1.x installation. And if there was a /system/ folder, they probably didn't change the system file name, which means it was easier-than-most to hack into. (Not so great.)

I agree: check the permissions on your index.php file, but also check the config.php file. If they have a backup, try restoring from that. The hackers may have tweaked something in that file...
> 1 votes

---
Tags: ee2, ee1
---


title: PayPal Adaptive Payments with CartThrob

text:
# Question
Title: PayPal Adaptive Payments with CartThrob
I'm working on a site that uses CartThrob as it's order handling system. We are using the PayPal Express payment gateway to collect the funds, but the problem is that the business model was really intended to use the PayPal Adaptive Payments API. Has anyone had any experience using the PayPal Adaptive Payments API with CartThrob? If so, I would love to have a conversation and determine how we can accomplish this.

Thank you, Lucas

# Answer
I finally got in touch with Chris Newton from CartThrob and they are going to be able to help us out with this. Thank you everyone who responded. I will let you all know how it goes.
> 1 votes

# Answer
Don't know if you would consider using Exp:resso Store instead or if you are already built out with CartThrob, but I needed to use PayPal Adaptive Payments and they were right on as far as offering to do custom work to build that out for me. The client decided to change the way their billing worked so we didn't need it, but I know Exp:resso could do it and would be willing. The Adaptive Payments is quite complex.
> 2 votes

# Answer
Reading between the lines here, I'm assuming you have or are creating a multi-vendor marketplace (e.g. Etsy, Devot:ee).

Every site I've seen do this using ExpressionEngine takes the money first, and pays out its vendors at the end of the month (as Devot:ee) do. While PayPal Adaptive Payments sounds like a nice idea, it makes it much harder to effect refunds etc, especially when customers come to you with a complaint about the vendor which you must resolve.

Without more information it's difficult to make a recommendation. Any decent PHP developer should be able to add Adaptive Payments support for you (and you would probably hard code into the extension some logic for looking up the Paypal seller email address in your database, then calculating the correct payment split etc, so it's not really something that would ever come built in to an e-commerce plugin).

However, you may find it's easier to simply pay out your vendors monthly, at least until your site grows to a point where it warrants a completely custom build (in a PHP or other framework, rather than a CMS).
> 1 votes

---
Tags: cartthrob, paypal, payment-gateway
---


title: Changing Member ID #s - possible?

text:
# Question
Title: Changing Member ID #s - possible?
This may be just me being a stickler for order, but sometimes I start a new project using an old database where I have to delete a bunch of data. Some of that data includes member info. Now, while deleting members, if I add a new one, the member ID assigned to that member is based on the previously added/deleted member. So if the last member was ID 200, the new member is ID 201.

However, if I delete it all down to the original 4 members, Member ID still follows the last one when I add the 5th member!

So it's like, Member ID 1, 2, 3, 4, then 201. Which looks super super odd.

IN SHORT:

If I delete members & add a new one, is it possible to have their member ID to be consecutive to current member IDs, not the deleted?

# Answer
> 8 votes
What you're referring to is the auto increment value in a table. You can change this by running the following query:

```
 ALTER TABLE mytable AUTO_INCREMENT = X

```

...where `X` is the **next** number you'd expect for your IDs.

This is a database-level change and not something ExpressionEngine has as a "feature". Only make this change if you understand you might break something.

> If I delete members & add a new one, is it possible to have their member ID to be consecutive to current member IDs, not the deleted?

Ultimately, I'd say "get over it" (as a friend, of course). Keeping the IDs in order is not worth the hassle (and potential risk) involved.

# Answer
> 6 votes
This is because all “id” columns in EE are set to AUTO\_INCREMENT in MySQL. Expressionengine is never explicitly choosing what the next member/entry/etc.’s ID is going to be – MySQL assigns it automatically.

MySQL stores the latest auto-increment value internally, and it won’t automatically drop it back when a row is deleted. Some tools like phpMyAdmin will let you reset the auto increment value. But it’s probably not a good idea to mess with it, especially when talking about EE, since other areas of the system might still be referring to that deleted member, via their now nonexistent member\_id. (Other systems solve this problem using foreign keys, but EllisLab chose not to use those in ExpressionEngine.)

---
Tags: members, database, mysql, member-details
---


title: DB Error on Upgrade from 2.5.3 to 2.5.5

text:
# Question
Title: DB Error on Upgrade from 2.5.3 to 2.5.5
I've just run through the upgrade process from EE 2.5.3 to 2.5.5 but when attempting to visit the control panel the following error is returned:

> A Database Error Occurred Error Number: 1054
>
> Unknown column 'session\_id' in 'field list'
>
> INSERT INTO `exp_security_hashes` (`date`, `hash`, `session_id`) VALUES (1358339646,'ab16daea8d642ede81116584166172107d5c30f1','3f3730359d532958f37f4de75c74e92c9747b441')
>
> Filename: core/EE\_Security.php
>
> Line Number: 118

Has anyone else run into this problem?

# Answer
The installer/update script doesn't create the missing column. You can create it manually if you're comfortable editing your database. I was updating from 2.4 to 2.5.5 and ran into the same issue.

As with anything you should back up your database BEFORE doing the update or this procedure.

Run the following SQL on your database;

```
ALTER TABLE  `exp_security_hashes` ADD  `session_id` VARCHAR( 40 ) NOT NULL DEFAULT  '0' AFTER  `date`

```

This will create the necessary column. You can then run the admin.php script and all should be well. I've just done it and everything came back to normal.

I'm not sure why this isn't automatically created. I haven't yet looked at the update script itself to see if it's missing or just failing for some reason.

UPDATE: There is a function in one of the update files (ud\_254.php) that changes the column `ip_address` to `session_id`. Whether that fails to execute because of permissions, a bug, or if the `session_id` column is used before is updated I do not yet know.
> 6 votes

# Answer
It looks like the installer didn't run properly and I suspect was a permissions issue. I set the appropriate permissions and then re-ran the installer and this time it seemed to run successfully and I could log back in to the control panel.
> 3 votes

---
Tags: database, upgrade
---


# Question
Title: Editing customized matrix fields in safecracker
I have a SafeCracker form where I've hard-coded the Matrix fields to customize the way they are displayed. It is working fine as an entry form, but I'm having trouble using it as an edit field.

My safecracker tag is wrapped in a channel entries tag, so I can get the values of the form fields when editing, but using the code below, when I have multiple matrix rows, the edit field just shows a single row, but with multiple values within each field.

Is there a way to get it to display multiple rows when editing?

```
<div class="name_relationship">
    <input type="hidden" name="form_name_relationship[row_order][]" value="row_new_0" />
    <label for="">Name</label>
    <input type="text" name="form_name_relationship[row_new_0][col_id_14]"  value="{form_name_relationship}{name}{/form_name_relationship}"/>
<label for="">Relationship</label>
<input type="text" name="form_name_relationship[row_new_0][col_id_15]" value="{form_name_relationship}{name}{/form_name_relationship}"/>
</div>
<p><a href="#" class="button radius tiny addname">+ Add Name</a> <a href="#" class="button     radius tiny remname">– Remove Name</a></p>
<script>
$(".addname").live('click',function(e){
    e.preventDefault();
    var $name_relationship = $("div.name_relationship:eq(0)");
    var $clone = $name_relationship.clone().html().replace(/row_new_0/g,'row_new_');
    $("div.name_relationship:last").after('<div                     class="name_relationship">'+$clone+'</div>');
})
$(".remname").click(function(e){
    e.preventDefault();
    if($("div.name_relationship").length > 1)
    {
        $("div.name_relationship:last").remove();
    }
})
</script>

```

# Answer
> 4 votes
You can use Matrix’s template tags to recreate the original rows:

```
{form_name_relationship}
    <div class="name_relationship">
        <input type="hidden" name="form_name_relationship[row_order][]" value="row_id_{row_id}" />
        <label for="">Name</label>
        <input type="text" name="form_name_relationship[row_id_{row_id}][col_id_14]"  value="{this_col_name}"/>
        <label for="">Relationship</label>
        <input type="text" name="form_name_relationship[row_id_{row_id}][col_id_15]" value="{that_col_name}"/>
    </div>
{/form_name_relationship}

```

Replace “`{this_col_name}`” and “`{that_col_name}`” with the actual column names.

---
Tags: safecracker, matrix
---


title: Pagination Links Don't Render

text:
# Question
Title: Pagination Links Don't Render
I am using {pagination\_links} and the code is not rendering.

Here is my complete code for my channel entries:

```
<section class="blog">

{exp:channel:entries channel="journal" disable="categories|category-fields|member-data" limit="1"}
<article class="blog-summary m-all t-all d1-d4 ">
<time>{entry_date format="%Y-%m-%t"}</time>
<h3>{title}</h3>

<div class="m-all t1-t2 d1-d2">
{journal_text_1}
</div>

<div class="m-all t1-t2 d3-d4">
{journal_text_2}
</div>

{exp:channel_images:images entry_id="{entry_id}"}
<figure class="blog-image m-all t1-t2 d-all"><img src="{image:url:large}"  alt="{image:description}"></figure>
{/exp:channel_images:images}

<hr class="m-all t1-t2 d-all m-clear t-clear d-clear">
</article>

<div class="m-all t1-t2 d-all m-clear t-clear d-clear">
{pagination_links}
    {page}
        <a href="{pagination_url}">{pagination_page_number}</a>
    {/page}
{/pagination_links}
</div>
{/exp:channel:entries}

</section>

```

And on the front end it renders like this:

{pagination\_links} {page} {pagination\_page\_number} {/page} {/pagination\_links}

Am I missing something?

NT

# Answer
You need to wrap the `{pagination_links}` tags with `{paginate}` tags:

```
{paginate}
    {pagination_links}
        {page}
            <a href="{pagination_url}">{pagination_page_number}</a>
        {/page}
    {/pagination_links}
{/paginate}

```

See this comment in the docs (which do a crap-tacular job of documenting pagination, btw).
> 9 votes

# Answer
The code looks correct to me. I don't think it's a required paramater but try adding `paginate='bottom'` to your channel entries open tag. That would make it:

```
 {exp:channel:entries channel="journal" disable="categories|category-fields|member-data" limit="1" paginate="bottom"}

```
> 1 votes

---
Tags: pagination
---


# Question
Title: Error when with referrer/upd.referrer.php when updating to 2.5.5
I was doing an update from 2.4 to 2.5.5 using Updater, it seemed to install EE but when it got to updating the modules it gave an error about the Referrer module and seemed to stop. It looks like the EE update worked fine, but if i try access the Referrer module it get this error

```
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Addons_modules::$dbforge

Filename: referrer/upd.referrer.php

Line Number: 156

Fatal error: Call to a member function modify_column() on a non-object in /system/expressionengine/modules/referrer/upd.referrer.php on line 156

```

Any ideas what's up?

# Answer
> 1 votes
Clicking the "update modules" button on the module admin area seemed to run the update. Although never got to the bottom as to why the upgrade failed on EE update or when visiting the referrer module page.

# Answer
> 1 votes
Try this... Open /system/expressionengine/modules/referrer/upd.referrer.php, add a new line just after line 141, then add the following to that new line:

```
$this->EE->load->dbforge();

```

Save to the server and try to access the Referrer module page.

# Answer
> 0 votes
I'd suggest reuploading the Referrer module's files as a first step. It's possible something got corrupted on the upload.

---
Tags: update, devdemon-updater
---


# Question
Title: Assets 2 Database Update Error on EE 2.5.1
Just ran into the following database error while upgrading from Assets 1.2.2 to 2.0.1. I'm running EE 2.5.1

```
A Database Error Occurred
Error Number: 1050

Table 'exp_assets_folders' already exists

CREATE TABLE `exp_assets_folders` ( `folder_id` int(10) UNSIGNED AUTO_INCREMENT, `source_type` varchar(2) DEFAULT 'ee' NOT NULL, `folder_name` varchar(255) NOT NULL, `full_path` varchar(255), `parent_id` int(10) UNSIGNED NULL, `source_id` int(10) UNSIGNED, `filedir_id` int(4) UNSIGNED, PRIMARY KEY `folder_id` (`folder_id`) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Filename: third_party/assets/upd.assets.php

Line Number: 430

```

I made sure the extension was enabled, then went to run module updates, confirmed DB was backed up and encountered this error.

# Answer
> 3 votes
I had previously attempted to try out the Assets 2 Beta, but upon receiving some PHP errors and not having time to test it out thoroughly, I restored a database backup.

This backup however, wasn't set to drop all tables in the database—only ones that were being imported.

After manually removing all tables and reimporting my database backup, I no longer received the database error when running the module updates.

---
Tags: assets
---


# Question
Title: Safecracker Return Message on Form Submission
Suppose I have a Safecracker form that will edit channel entries. Once the entry is edited I want to display something like "Thanks for editing your entry" on the edit entry page. How would I go about displaying a thank you message on successful form submission? I do not want to be redirected to another page.

Here is example code.

```
{exp:safecracker channel="channel_name" return="channel_name/edit/ENTRY_ID" entry_id="{segment_3}"}

Title:<input name="title" type="text" value="{title}">
<br/><input type="submit" value="Submit">

{/exp:safecracker}

```

# Answer
> 1 votes
It sounds like you are looking for an AJAX-style contact form where you display the success or failure message on the same page without a refresh. I might suggest this article: Creating a modern AJAX contact form in ExpressionEngine. It also mentions the difference between adding AJAX to EE's native contact form and adding AJAX to other form add-ons like Solspace's Freeform.

Alternatively, you can reload the same page/template but add another URL segment, like:

```
return="channel_name/edit/ENTRY_ID/success"

```

Then you can display a success message on that same template when the segment matches:

```
{if segment_4 == "success"}
    <p>Success message here</p>
{/if}

```

This does not offer inline validation, like AJAX will, but it is a simple option.

---
Tags: safecracker, entry
---


# Question
Title: Example advanced search form allowing no keywords
Basically, I didn't need anything fancy. The simple example with some stripped out pieces would suffice, but I would like them to be able to simple search all entries by author, or any other segment for that matter. The problem I run into is every time I submit the search, I am told "You did not submit a search term." from the standard EE error screen. I have usually just built my searches but figured it would be better to use the search module as is rather than allowing PHP.

My template is as follows. Am I missing something simple here?

```
{exp:search:advanced_form result_page="search/results" no_result_page="search/no_results" channel="blog_post" status="not_closed" search_in="everywhere" where="all" show_expired="no" show_future_entries="no"}
    <table cellpadding='4' cellspacing='6' border='0' width='100%' style="margin: 1em 0 0 0;">
        <tr>
            <td colspan="2">
                <fieldset class="fieldset">
                    <legend>{lang:search_by_keyword}</legend>
                    <input type="text" class="input" maxlength="250" name="keywords" style="width:100%;" />
                </fieldset>
            </td>
        </tr>
    </table>
    <table cellpadding='4' cellspacing='6' border='0' width='100%' style="margin: 1em 0 0 0;">
        <tr>
            <td width="50%">
                <fieldset class="fieldset">
                    <legend>Search by Author</legend>
                    <div class="default">
                        <select name="where">
                            <option value="any" selected="selected">Any</option>
                            {snippet_active_authors}
                        </select>
                    </div>
                </fieldset>
            </td>
            <td width="50%">
                <fieldset class="fieldset">
                    <div class="defaultBold">{lang:categories}</div>
                    <select name='cat_id[]' size='5'  class='multiselect' multiple='multiple'>
                        <option value='all' selected="selected">{lang:any_category}</option>
                        {snippet_active_categories}
                    </select>
                </fieldset>
            </td>
        </tr>
    </table>
    <table cellpadding='4' cellspacing='6' border='0' width='100%' style="margin: 1em 0 0 0;">
        <tr>
            <td valign="top" width="50%">
                <fieldset class="fieldset">
                    <legend>{lang:search_entries_from}</legend>
                    <select name="date" style="width:150px">
                        <option value="0" selected="selected">{lang:any_date}</option>
                        <option value="1" >{lang:today_and}</option>
                        <option value="7" >{lang:this_week_and}</option>
                        <option value="30" >{lang:one_month_ago_and}</option>
                        <option value="90" >{lang:three_months_ago_and}</option>
                        <option value="180" >{lang:six_months_ago_and}</option>
                        <option value="365" >{lang:one_year_ago_and}</option>
                    </select>
                    <div class="default"><br /></div>
                    <div class="default">
                        <input type='radio' name='date_order' value='newer' class='radio' checked="checked" /> {lang:newer}
                        <input type='radio' name='date_order' value='older' class='radio' /> {lang:older}
                    </div>
                </fieldset>
            </td>
            <td valign="top" width="50%">
                <fieldset class="fieldset">
                    <legend>{lang:sort_results_by}</legend>
                    <select name="orderby">
                        <option value="date" >{lang:date}</option>
                        <option value="title" >{lang:title}</option>
                    </select>
                    <div class="default"><br /></div>
                    <div class="default">
                        <input type='radio' name='sort_order' class="radio" value='desc' checked="checked" /> {lang:descending}
                        <input type='radio' name='sort_order' class="radio" value='asc' /> {lang:ascending}
                    </div>
                </fieldset>
            </td>
        </tr>
    </table>
    <table cellpadding='4' cellspacing='6' border='0' width='100%' style="margin: 1em 0 0 0;">
        <tr>
            <td colspan="2">
                <fieldset class="fieldset">
                    <div class='searchSubmit' style="text-align: right;">
                        <input type='submit' value='Search' class='submit' />
                    </div>
                </fieldset>
            </td>
        </tr>
    </table>
{/exp:search:advanced_form}

```

Thanks all.

# Answer
If there isn't a member\_name, a search term is required when using the native ExpressionEngine search tag so you must add the keyword field back in:

```
<input type="text" name="keywords" id="keywords" maxlength="100" size="20" />

```

If you don't want the keyword, you can hack the Search module to remove the code that requires the keyword or you can look at the paid search addons that are available: **Super Search** or **Low Search**.
> 1 votes

---
Tags: ee2, search
---