We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Tome Mod and site index templates

Development and Programming

Thorvald's avatar
Thorvald
10 posts
about 18 years ago
Thorvald's avatar Thorvald

I’m developing two static-content heavy sites at the moment, and am trying to use Mr Huot’s Pages mod to run basically everything. I’ve got the index template of the group set to be the default static template, and pull dynamic content into it in a couple of places from other weblogs. It makes for a really clean template structure, easy menus, minimal hard-coding and gives the client the ability to add new menu-items through the CMS. Perfect!

It’s just dreamy, until … I try to look at the site by entering just the root URL.

I want www.mysite.net or www.mysite.net/index.php to show the same thing as www.mysite.net/index.php/home, but it seems that when the category isn’t specified in the URL the mod’s global variables don’t get defined, and the menus collapse in a heap of dust and a really nasty parse error.

Have I run up against a natural limit of the Pages mod, or am I missing something?

[Mod Edit: Moved to the Modules forum as it is more appropriate. Also re-titled to avoid confusion with the first-party Pages module.]

       
Christopher Simmons's avatar
Christopher Simmons
68 posts
about 18 years ago
Christopher Simmons's avatar Christopher Simmons

Off the top of my head, it seems like you could do something like

{if static_page == ""}{assign_variable:static_page="home"}{/if}

at the beginning of your template.

       
Eric Barstad's avatar
Eric Barstad
198 posts
17 years ago
Eric Barstad's avatar Eric Barstad

Thorvald, did you ever get this worked out? If so, I’d love to hear the solution as I’ve run into the same problem.

       
Thorvald's avatar
Thorvald
10 posts
17 years ago
Thorvald's avatar Thorvald

Yeah, I did. Figured out Evil Spy’s solution about 10 minutes before he suggested it. 😛

{if static_page == ""}{assign_variable:static_page="6"}{/if}

Or, whatever your index-category ID happens to be.

       
Eric Barstad's avatar
Eric Barstad
198 posts
17 years ago
Eric Barstad's avatar Eric Barstad

Yeah, I got that to work for the content (took me a while to figure out I had to use the category ID and not the name), but my menus still don’t work – maybe because my menus are embedded. I’ll keep experimenting. 😊

Thanks for the reply.

       
Thorvald's avatar
Thorvald
10 posts
17 years ago
Thorvald's avatar Thorvald

Ah. Menus.

Here’s my solution:

<div id="menu" class="heading">    
<ul> 

    {if static_page == ""}
        {exp:weblog:categories weblog="content" parent_only="yes" style="linear" show_empty="no"}
        
        <li>
            <a href="http://{path=}<?php" title="Link to {category_name}"> {category_name}</a>
          </li>

        {/exp:weblog:categories}

    {if:else}
        {exp:static_page_path direction="post" nest="false" page="0" depth="1" show_empty="no"}

             <li>
                <a href="http://{url_title}" title="Link to {title}" class="current">{title}</a>
              </li>

        {/exp:static_page_path}
    {/if}
</ul>
    
</div>

Looking at it with fresh eyes, though. I might be able to use an embed variable to pass the static page id into the sub-template. Hmmmmm.

       
Eric Barstad's avatar
Eric Barstad
198 posts
17 years ago
Eric Barstad's avatar Eric Barstad

That looks a lot like what I came up with. Thanks for sharing.

       
Thorvald's avatar
Thorvald
10 posts
17 years ago
Thorvald's avatar Thorvald

Cool.

What did you come up with? I’m having trouble adapting this to another site I’m building – cut and paste ftl, I guess. Might help to see your solution.

       
Eric Barstad's avatar
Eric Barstad
198 posts
17 years ago
Eric Barstad's avatar Eric Barstad

Well, it’s kind of a mess, but here’s my main nav (parents only):

<div id="mainnav">
{if seg_1 == "index.php" && seg_2 == ""}
   <?php $count = 1; ?>
   <ul>
   {exp:weblog:categories weblog="pages" style="linear" show_empty="yes" parent_only="yes"}
    <li><a href="http://{site_url}{category_url_title}class=page_<?=$count++?>">{category_name}</a></li>
   {/exp:weblog:categories}
   </ul>
{if:elseif seg_1 == ""}
   <?php $count = 1; ?>
   <ul>
   {exp:weblog:categories weblog="pages" style="linear" show_empty="yes" parent_only="yes"}
    <li><a href="http://{site_url}{category_url_title}class=page_<?=$count++?>">{category_name}</a></li>
   {/exp:weblog:categories}
   </ul>
{if:else}
   <?php $count = 1; ?>
   <ul>
   {exp:static_tome_path direction="post" page="0" depth="1" nest="false"}
       <li><a href="http://{url_title}class=page_<?=$count++?>">{title}</a></li>
   {/exp:static_tome_path}
   </ul>
{/if}
</div><!-- #mainnav -->
       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

If you can get away with some php in your embeded template I added:

<?php 
  global $IN;
  if(!isset($IN->global_vars['static_page'])){
    $IN->global_vars['static_page'] = 'your_index_cat_id';
  }
?>

which seems to be working fine. Your template needs to allow PHP Input.

       
syrupcore's avatar
syrupcore
20 posts
17 years ago
syrupcore's avatar syrupcore

Hi,

I’m having similar problems with static_tome_path. I can’t get the menu to appear on my home page. I’ve tried a few of the solutions above to no avail.

I have this in my site’s header template.

{if static_page == ""}{assign_variable:static_page="35"}{/if}

Where 35 is the ID of the tome page for /home - a top level category.

I might could just pull some redirect stuff via apache but seems like other people have worked this out without resorting to that. What am I missing? Here’s my menu code:

<div id="nav">
        {exp:static_tome_path direction="post" page="0" depth="0" }
            <a href="http://{url_title}" title="Link to {title}" class="{short_name}-nav">{title}</a>
        {/exp:static_tome_path}
    </div>

The menu lives in the footer include. I tried sticking the if statement in my footer as well, just in case, to no avail.

Thanks for any insight.

Will

       
syrupcore's avatar
syrupcore
20 posts
17 years ago
syrupcore's avatar syrupcore

pretty please?

       
Dan Lewis's avatar
Dan Lewis
24 posts
17 years ago
Dan Lewis's avatar Dan Lewis

Not sure if it is a similar issue or not. I don’t use static_tome_path tag to generate the menu in my embedded file becuase the file may be included from either a Tome page or standard EE page. I just use exp:weblog:categories to populate the menu.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.