[TYPO3] weird T3 template problem

Christopher Torgalson bedlamhotel at gmail.com
Sun Sep 30 21:45:14 CEST 2007


Hi,

On 9/30/07, Andrew Hill <andrew at salamander.net> wrote:
> hi folks,
>
> i have the strangest problems - i hope someone has some insight.
>
> i was asked to make a site that has a horizontal menu for 5 main site
> sections, and has a vertical menu for each one of those sections.  i
> simply hard-coded a set of 5 links into my html template, and created
> 5 variations of that template, and applied each one to a set of pages
> in my site.
>
> here is my site: www.youcanstaysharp.com
>
> the problem is, the root level page comes up the first time, but from
> there if any of the horizontal html links are clicked, T3 puts the
> user into one of the pages, and doesn't respect the fully qualified
> url in the html links!
>
> e.g. "The Science" is hardcoded into the template as http://
> www.youcanstaysharp.com/index.php?id=274, and "Home" is hardcoded
> into the template as http://www.youcanstaysharp.com/ but once you
> click away from "Home" you are always put into "Programs" (which has
> a url of http://www.youcanstaysharp.com/index.php?id=252) regardless
> of which link you click on.
>
> it's very strange!  i'm at my wits end with this, and am willing to
> pay for support if anyone wants to help.


Firstly, what you say is happening is NOT what I see when I visit your
link. All the links DO take you to different pages as you will observe
if you look at the url in the address bar after you click a link;
also, the markup changes on some pages, so we can be positive that the
problem is not what you describe.

What I suppose you're talking about is the fact that the 'Programs'
menu item in the top nav always appears to be 'active'. I would also
guess that this has something to do with what you said in a later
message in the thread:

> i used TV to create 5 different "sites", one for each template i'm
> using.  the only differences in each template (except for home) is a
> css class to make that item "active" so i can color it differently.

If this means what it sounds like it means (i.e. if you have truly
used five separate templates for no other reason than to change a
class attribute), it's a **very** odd strategy, and totally
unnecessary. It will create quite a lot of extra work for you if ever
you change the site (so may the fact that your layout uses tables, but
that's another thread...)

The problem is probably caused by the fact that one or more pages do
not end up with the right template set--but again, this is completely
unnecessary in the first place.

To solve your immediate problem, I'd say there is a simple solution:
do it like the FTB tutorial does it [1]. In other words:

1.  Use a single template if you only have a single page layout
2.  Make the menu a library object using HMENU
2a. Make sure the HMENU is capable of displaying the active page
3.  Map a TS object to the appropriate region in your template

On any given page, your menu looks something like this:

td class="hnav_item" width="158"><a
href="http://www.youcanstaysharp.com">home</a></td>
            <td class="vertical_spacer" width="2">&nbsp;</td>
            <td class="hnav_item" width="159"><a
href="http://www.youcanstaysharp.com/index.php?id=252">programs</a></td>
            <td class="vertical_spacer" width="2">&nbsp;</td>

            <td class="hnav_item_active" width="158"><a
href="http://www.youcanstaysharp.com/index.php?id=274">the
science</a></td>
            <td class="vertical_spacer" width="2">&nbsp;</td>
            <td class="hnav_item" width="159"><a
href="http://www.youcanstaysharp.com/index.php?id=296">quotations</a></td>
            <td class="vertical_spacer" width="2">&nbsp;</td>
            <td class="hnav_item" widthth="158"><a
href="http://www.youcanstaysharp.com/index.php?id=318">links</a></td>


...which means you will need to make a library item something like this:

lib.top_menu = HMENU
lib.top_menu {
  1 = TMENU
  1 {
    noBlur = 1
    wrap = <tr class="top_nav" width="800" align="center" height="30">|</tr>

    NO {
      ### The menu items have alternating widths; for more info on
this syntax search Google for 'optionsplit' or check out [2]
      ###
      allWrap =  |*| <td class="hnav_item" width="158">|</td><td
class="vertical_spacer" width="2">&nbsp;</td> || <td class="hnav_item"
width="159">|</td> |*|
    }

    ACT = 1
    ACT {
      allWrap =  |*| <td class="hnav_item_active"
width="158">|</td><td class="vertical_spacer" width="2">&nbsp;</td> ||
<td class="hnav_item_active" width="159">|</td> |*|
    }
  }
}


Tested and working. This is by far the easiest way to approach your problem.

-- 
Christopher Torgalson
http://www.typo3apprentice.com/

[1] http://typo3.org/documentation/document-library/tutorials/doc_tut_ftb1/1.0.1/view/1/2/#id3038221
[2] http://typo3.org/documentation/document-library/core-documentation/doc_core_tsbyex/0.0.16/view/7/5/


More information about the TYPO3-english mailing list