Results 1 to 5 of 5

Thread: One ore more module templates (tpl)

  1. #1
    New user
    Join Date
    02-03-10.
    Posts
    3

    Default One ore more module templates (tpl)

    Hello,

    I'm working on creating my first template for Typolight. I have never worked with PHP before, but I have some good experience with ASP.NET programming and skinning, mostly in DNN. I have a question about creating more then one different module templates for Newslist module. I need one newslist module to include links to the archive page at the bottom and one that does not include those links. I'm not talking about display templates (short,latest...), because these templates gets repeated and would display the link under every news in the list. Is it possible to create two different templates, one would be newslist.tpl and the other newslist_link.tpl?

    Thanks,
    Nejc

  2. #2
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: One ore more module templates (tpl)

    That question was asked recently and I believe the answer is currently no, you can't easily create separate templates:
    viewtopic.php?f=7&t=1127&p=4333&hilit=news+templat es#p4333

    It would be nice -- there's been a couple of times where I wish I had it as well.

    A workaround for your situation specifically would be to create the link separately, perhaps as a custom HTML module. Then include that module only to the page(s) you want the link to appear. Or maybe you can do some logic in the template to show or hide the link based on page alias or something.

    I've been wondering if there was a way to create your own module that extended the ModuleNewsList.php class with essentially only the template being different. But I don't have the knowledge to do it, or if it's worth the effort.

    Does anyone else know if this is possible and relatively painless?
    Brian

  3. #3
    New user
    Join Date
    02-03-10.
    Posts
    3

    Default Re: One ore more module templates (tpl)

    Yes, I had to solve the problem by using the custom HTML module. I'll dig deeper when I find some time to spare...Thank you for your answer.

  4. #4
    User
    Join Date
    06-29-09.
    Posts
    271

    Default Re: One ore more module templates (tpl)

    I never used the newslist, so I'm guessing here. But if you can give the module a id or css class you can have the php code read the class and use the part of the template you'd want it to.
    pseudocode:
    Code:
    <?php
    switch ($classname) {
    case 'link':
    ?><html><a>link</a></html><?php
    default:
    ?><html><lalala /></html><?php
    break;
    }
    ?>
    Or like Ben suggests: use css to show or hide the link?

  5. #5
    New user
    Join Date
    02-03-10.
    Posts
    3

    Default Re: One ore more module templates (tpl)

    @Vera
    The code worked great! Thank you very much.

    For some other elements I just simply used the display CSS property.

    Thanks again, great community!
    Nejc

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •