2

When entering content, is there a way to mistake-proof entering links to other url-titles on the site without entering the full URL?

I am setting up an EE website using Structure and Low Variables. Structure is managing the "page" content in a channel called "Pages," and there are several other channels for various dynamic content listings. I am using Low Variables to manage snippets of code, various settings, and bits of content such as company contact information.

As part of the home page, I have several "featured" sections with similar formatting. Each has the option for a title, image, link, and blurb of text. The client would like to be able to select from any content on the site (as well as presumably content NOT on the site). I setup a channel called "Features" with the following fields: title (Text Input),feature_url (Text Input -- default text formatting "None"), feature_image (File), and feature_body (Textarea).

The client would select which entries from the "Features" channel to display on the Home page using a select list in Low Variables.

I setup the Home page template as follows:

<!-- Feature Section -->
<div class="row">
    {exp:channel:entries channel="Features" dynamic="no" limit="3" disable="{lv_shortcuts_disable_default}"}
    <div class="column one-third">
        <div class="pic">
            {feature_image}{if feature_url != ""}<a href="{feature_url}">{/if}<img src="{url:feature3}" alt="" />{if feature_url != ""}</a>{/if}{/feature_image}
        </div>
        <h3>{if feature_url != ""}<a href="{feature_url}">{/if}{title}{if feature_url != ""}</a>{/if}</h3>
        <p>{feature_body}</p>
    </div>
    {/exp:channel:entries}
</div>
<!-- Feature Section::END -->

When entering content, I have tried typing in the url_title of another page on the site, but the template wraps the url_title in <p></p> tags when rendering. (Example: entering "/index.php/our-work" in the entry field yields http://localhost:8080/mysite/<p>/index.php/our-work</p>.) Entering a full URL which includes "http://" works as expected. Also, if the url_title of the other entry changes this entry will have a broken link.

So I guess I have two problems:

  1. First, I would like an easy way for my client to select from existing content "pages" in a way that is straightforward and mistake-proofed if the url_title of a page changes. Ideally, this would be a select list. (If they want to enter a link to an external page, I could have a separate variable for that.)
  2. Second, I need those relative links to display in the template correctly without being wrapped in paragraph tags.

Does anyone have any experience with doing something like this? Any advice to help me?

3 Answers 3

2

It's odd that you are getting p tags with formatting set to none. Was this a different field type at one point? Try deleting out any data, saving the entry, then editing it again, add the url once more and finally saving of course.

Just some thoughts that might help you (or others) though, might be slightly to one side of your current situation; if that makes sense?

There is an add-on which is very nice for featured type entries called Selected items:

Often on a website you want to control the order that entries display. For example, on a magazine-style website, the front page stories would be editorially selected rather than just the 5 most recent.

Selected Items (docs are at the repo/download itself)

If all you are ever doing is linking to entries in the Page channel, for example, where the data is exactly the same as what you've built in your "Featured" channel then this route would eliminate the need for having two channels that the client has to fill out. You could just pull from the Page channel in this case assuming the data is the same like I said. Any chance you have that the client has less work to do is a plus IMO.

The possible downside to this add-on is that it adds a new location to the CP for the client to have to manage. This can be alleviated a bit via adding a "bookmark" in any editors/admin accounts via the Add+ link in the main nav or better yet by using something like Zoo Flexible Admin.

Another idea would be to add a link to the top of Structure labeled "Featured", for example, which is a shortcut to the selected items page. This would require an add-on of course similar to Encaf Where is the LV.

Another option which might work is via Low Reorder. In this case you might set a status or category of "Featured" and only have those entries from the Page channel show up. You could reorder though, the difference here from Selected items is that with Selected Items you can reorder AND select which items you want to show. Low Reorder you can reorder but, the selection process is done more automatically depending on how you setup your options and filters etc.

Finally, if for some reason you can't figure out why your current setup keeps adding p tags then maybe try a different field type all together for now. There is the VZ URL add-on which would work in this case:

VZ URL

Note: using VZ URL only is "bandaging" the problem. Finding out why you're getting p tags in a text input field type with formatting set to none of course would be the real fix vs this bandaid fix. I'm not sure why this is happening from where I sit, however.

4
  • Thank you, Natetronn. Several things here look useful. In the Featured Items, my client wants to be able to either highlight specific content pages, highlight a specific News item, or enter a bit of unrelated text (with image) which may or may not link to anything. I'll check out the add-ons you suggested and see if they could work.
    – Amy Witty
    Commented Jan 18, 2013 at 22:00
  • Also, I can't remember if I had the URL as a different fieldtype originally -- didn't think so. I will try deleting it and recreating it and see if that works.
    – Amy Witty
    Commented Jan 18, 2013 at 22:00
  • Trying something: in my Features channel, I setup a relationship field to a related page (Pages channel). When I enter content, I see the titles of my Structure pages in the dropdown. However, in my template, I'm having a hard time getting the link working to the related page because some have parent segments and some do not. How do I reference the Structure page in the a tag? {related_entries id="feature_related_page"} <a href="{url_title_path=''}"><img src="{page_image:feature3}" alt="" /></a> <h3><a href="{url_title_path=''}">{/related_entries}{title}</a></h3>
    – Amy Witty
    Commented Jan 20, 2013 at 4:27
  • I think starting a new question for this one is in order because, we are now branching off a bit :)
    – Natetronn
    Commented Jan 20, 2013 at 4:38
1

1) In the past I used to use Wygwam as my textarea field type and this has a handy plugin called Wygwam Entries which can be used to link to any channel (not just those in the pages module). Both of those are commercial however. There is a free linking addon called Wygwam Structure Pages though which I believe still works but I'm not sure if it's still supported.

Actually having just taken a look at Wygwam it now seems to include Structure Page support by default so it's all there in one addon.

Another alternative commercial option but a bit cheaper is Redactee. I believe allows you to link to channel entries (it should support Structure pages too) in a similar way.

Lastly if you don't want commercial and just use the Pages module then Easy Page Links provides an easy to use interface but unfortunately it doesn't support Structure as far as I know.

That provides a few options at least.

2) I believe that's just because you've set the formatting of the field to XHTML which is probably the default. If you set this to 'None' in wont add the paragraph tags to the URL but it also wont add XHTML to anything else in the textarea. If you're using one of the above page linking addons however then you can keep the formatting to XHTML and just tell them how to link to internal pages by selection.

Hope that helps.


2
  • FYI: I'm pretty sure you can't use the Pages module with Structure and in the past it's been know to do some crazy stuff if you try enabling Pages with Structure on or vice versa.
    – Natetronn
    Commented Jan 18, 2013 at 20:49
  • Ian, thanks for your reply. I do already have the field formatting set to "None", which is why this was so strange. I'm going to try deleting the field and recreating it.
    – Amy Witty
    Commented Jan 18, 2013 at 22:03
0

The key to fixing problem #1 (URL's not including the full path but just the url_title) was to use Structure's {page_url} tag in the template markup. {page_url} gives the Structure URL with parent segments included (example: "about-us/donate" instead of just "donate"). Thanks to @Travis Schmeisser for his help in the Structure support forum.

As for #2 (p tags wrapping the url_title), I did delete the field from the field group then recreated it. The problem is now solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.