ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Create a new weblog/template dynamically

January 23, 2009 5:56am

Subscribe [2]
  • #1 / Jan 23, 2009 5:56am

    sosolatin

    10 posts

    Hey guys,

    Firstly, thanks for all the awesome info in this forum, there is always well structured answers on all the questions I’ve been investigating.

    I have a client who wishes to change the sub menu items of their navigation menu. I’ve seen loads of answers to overcome this, the one best suiting my needs being to create a weblog for the sub-navigation and allowing them to edit the items.

    The next question is the tricky one: The client wants to be able to add/remove items from the list also. Remove is easy enough, but adding a new submenu item requires the admin to add a sub menu item, then somehow associate a new weblog they create to it.

    so to break it down… the client would like to:

    1. log in to control panel
    2. add a new submenu item to “About us” called “the section”
    3. create a new weblog add the content to and a predefined template to show the content.
    4. link the newly made weblog/template to the submenu item inside the navigation blog (i.e the new href for this link is “{path=aboutus/thesection}”

    I assume lots of you have overcome an issue like this, would be interested to hear how.

    Thanks in advance

  • #2 / Jan 23, 2009 6:13am

    Brian Hildreth

    45 posts

    Hello,

    I just had a similar project. I structured my site like this. I had a template that called in a particular weblog and called it something like “About Page”. And then I created a category group and assigned this to that weblog. Now each time the client wants to create a item in the sub-nav, all he has to do is publish a new entry to that weblog and assign it a category, or add a new category right from the publish screen.

    Then I use the the weblog categories tag to display the navigation. This seems to work out really well, and the client likes it because it makes sense to them and they can do everything from one publish screen and one weblog.

  • #3 / Jan 23, 2009 8:01am

    sosolatin

    10 posts

    thanks man - that’s very helpful. You dont happen to have a snippet of link code you used to connect the href to the template and pull the weblog entries info?

  • #4 / Jan 23, 2009 8:12am

    sosolatin

    10 posts

    I nutted it out actually - thanks for the help; I had been wondering for a while how I could take advantage of the categories!

    Cheers mate.

  • #5 / Jan 23, 2009 1:59pm

    Brian Hildreth

    45 posts

    Cool, glad to hear that you have it working. Here is my code for my sub_nav anyway in case you needed something.

    <h4>Company Sections</h4>
    <p><ul><br />
    {exp:weblog:entries weblog="company_page" sort="asc" status="open" category="34" limit="1"}<br />
    {if segment_2 == "{url_title}"}<br />
    <li class="selected"><a href="http://{url_title_path=company}">{title}</a></li><br />
    {if:else}<br />
    <li><a href="http://{url_title_path=company}">{title}</a></li><br />
    {/if}<br />
    {/exp:weblog:entries}<br />
    {exp:weblog:entries weblog="company_page" status="open"}<br />
    {categories}<br />
    {exp:selected item="{category_name}" replace="class='selected'"}<br />
    {/categories}<br />
    {/exp:weblog:entries}<br />
    {exp:weblog:categories weblog="company_page" style="linear" status="open" show_empty="no" show="not 34"}<br />
    <li {selected_{category_name}}><a href="http://{path=company/details/}">{category_name}</a></li><br />
    {/exp:weblog:categories}<br />
    {/exp:selected}<br />
    </ul><br />
    </div><br />
    

    Now I have two things going on here. First, I always wanted the first link to be the "about us" from that company weblog. so I used this code.
    <br /> {exp:weblog:entries weblog="company_page" sort="asc" status="open" category="34" limit="1"}<br /> {if segment_2 == "{url_title}"}<br /> <li class="selected"><a href="http://{url_title_path=company}">{title}</a></li><br /> {if:else}<br /> <li><a href="http://{url_title_path=company}">{title}</a></li><br /> {/if}<br /> {/exp:weblog:entries}<br />

    And then I wanted the navigation to have a little marker that highlights the current page. I used solspace.com's selected plugin for this.

    <br /> {exp:weblog:entries weblog="company_page" status="open"}<br /> {categories}<br /> {exp:selected item="{category_name}" replace="class='selected'"}<br /> {/categories}<br /> {/exp:weblog:entries}<br /> {exp:weblog:categories weblog="company_page" style="linear" status="open" show_empty="no" show="not 34"}<br /> <li {selected_{category_name}}><a href="http://{path=company/details/}">{category_name}</a></li><br /> {/exp:weblog:categories}<br /> {/exp:selected}

    Hope that helps as well.

  • #6 / Jan 23, 2009 11:34pm

    sosolatin

    10 posts

    Thanks man.

    I managed to sort that out great thanks to your help, but have run into another problem thats related.

    I’m just tidying up the url and in the ‘weblog global preferences’, set the ‘Use Category URL Titles In Links?’ to yes and gave the Category URL indicator a name of ‘bob’ for testing.

    I found when I turn this setting on, the linking to the page works, but doesn’t publish the content for that weblog.

    I read this thread, not sure if this is related: http://ellislab.com/forums/viewthread/100321/#507413

    This is the code for the sub-menu:
    <br />     <ul><br />       {exp:weblog:categories weblog="about"}                    <br />       <li><a href="http://{path=about/index}">{category_name}</a></li><br />       {/exp:weblog:categories}<br />     </ul><br />

    code in the template ‘about/index’:
    <br />     {exp:weblog:entries limit="1"}<br />       {maindescription}<br />       {leftcolumn}<br />       {rightcolumn}<br />     {/exp:weblog:entries}<br />

    If anyone could shed light on this that would be greatly appreciated.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases