0

I have the following code

<div id="navbar" class="collapse navbar-collapse">
    <ul class="nav navbar-nav">
        {exp:channel:entries channel="static" sort="asc" dynamic="off"}
            <li><a href="{url_title}">{title}</a></li>
        {/exp:channel:entries}
    </ul>
</div><!--/.nav-collapse -->

Which is looping through a channel I have for static pages on my website. Technically it is showing all the stuff it should do. This is the code it outputs:

<div id="navbar" class="collapse navbar-collapse">
    <ul class="nav navbar-nav">
        <li><a href="small-builders">Small Builders</a></li>
    </ul>
</div>

However, when I click the link it gives me a white page. I have the htaccess from the documentation set up. I'm new to ExpressionEngine. Am I missing something completely obvious? I just want to link the the entry I've created.

2
  • Could you add the actual URL you get redirected to when you click the link? We need some context, and also please post your .htaccess file if you believe this to be an issue.
    – jrothafer
    Commented Dec 10, 2015 at 15:18
  • The only way i've fixed it currently is to enable the Pages plugin and use that to choose which template to use for pages. The link the above goes to is www.ee3.dev/small-builders - problem is i wasnt aware how to assign a template to the static channel i have so it wasn't loading anything. Htaccess is fine Commented Dec 10, 2015 at 15:20

2 Answers 2

2

In ExpressionEngine, unlike in other CMS's, templates aren't assigned to channels. Templates are loaded based on template group/template name convention, and those templates display the content of whatever channel (or channels) you specify in the channel:entries tags that you use in those templates. (See docs on URL structure.)

Generally then, you'd link to an entry using {url_title_path="template_group/template"}. So if you used {url_title_path="www/static"}, your link would end up as example.com/www/static/small-builders. A channel:entries tag in the static template would then automatically load the content from the small-builders entry (so long as the channel parameter was correct).

But it sounds like you want your URL to simply be example.com/small-builders, in which case you're correct that using the Pages module is the way to go, as you can set an arbitrary (and absolute) URL, and assign the template you want to use no matter where it resides in your template structure.

0
<div id="navbar" class="collapse navbar-collapse">
    <ul class="nav navbar-nav">
        {exp:channel:entries channel="static" sort="asc" dynamic="off"}
            <li><a href="{url_title_path='channel/template'}">{title}</a></li>
        {/exp:channel:entries}
    </ul>
</div><!--/.nav-collapse -->

This will output

<div id="navbar" class="collapse navbar-collapse">
    <ul class="nav navbar-nav">
        <li><a href="http://yoursite.com/index.php/channel/template/small-builders">Small Builders</a></li>
    </ul>
</div><!--/.nav-collapse -->

Hope it helps!

Ref: https://docs.expressionengine.com/v2/add-ons/channel/channel_entries.html#url-title-path

7
  • White page still, the static template has a layout but it just shows nothing Commented Dec 10, 2015 at 14:47
  • I have an entry called Small Builders, this is inside the static channel. The template for static has a layout so I'd know if it loads, however everything i try just renders a white page Commented Dec 10, 2015 at 14:48
  • Saying that, i've created a template inside my www template group to use on my static channel, however i'm not actually sure it's connected. Do you know how to do that? Commented Dec 10, 2015 at 14:58
  • Bring up "www.example.com/index.php/site/index" where site is the template group you have created. Try putting some static content in your template, i.e. without the {exp:channel:entries} ... {/exp:channel:entries} loop. Whatever you put into your template should be shown by EE, even if there is no dynamic content at all.
    – Ingmar
    Commented Dec 10, 2015 at 15:09
  • My template group is www and inside that i have index and static. Index works fine, I just didn't get how to get my static channel to use the static template inside www. The only way i've got it to work is to enable to pages add on and manually select the template Commented Dec 10, 2015 at 15:23

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.