Fork me on GitHub

number of templates associated with pnrender mods, excessive  Bottom

  • Hi there,

    I have been fooling around with Smarty for the past few days and I have in fact just templated out a module for MD-pro with it. I was amazed at the flexibility along with the enhanced productivity to work flow.

    After completing the module I thought I would take a quick spin around the example module attached to pn760 - all looked we and good until I opened the pntemplates folder - there are 20 template files in this folder, in fact every pnrender mod I have seen so far has an excessive amount of these files.

    When I smartied up my module I finished up with 3 templates (could have been two if I really tried), two for the module and one for a block, but even if I had of micro tuned everything down to seperate menu components, etc it would not have been 20. ALL of the module's markup is contained in my 3 templates and it amazes me how one could come up with 20 odd template files.

    Primarily a visual developer, I tend to like all the layout in one place (or only a few places) as this give me a good view of what is going on and the ability to flick out complex layouts very quickly. The current amount of templates attached to these mods would frustrate the hell out of me - even operating with 3 when I made my module was quite time consuming flicking between these files, userapi, user , lan define, Smarty assignments, templates - I don't know about you, but for me having 20 templates to deal with is far too much fragmentation to deal with.

    Now I ask, surely there can't be a need for this amount of templates? Is it due to the fact that one is used for each function, etc? Could it be a good idea to change the modules are made - I have noticed that the seperate functions seem to cause fragmentation when using Smarty...

    -Lobos

    --
    -Lobos
    Professional PHP Framework Services: Concept, Development and Deployment
  • Lobos,

    Bear in mind that the example module is just that an example of the various techniques that can be used. The current example module has 21 templates. If you don't use the interactive install feature then you don't use 5 of those templates.

    We do use one template for each function as this simplifies the structure. The function modname_type_func equates to the template modname_type_func.htm. There is then the admin/user navigation in two further templates.

    Each block then has two templates one for the user output and one for the admin interface.

    There's only one consolidation I can think of and that's the new/modify templates as these tend to be the same apart from the modify template containing the item id and values of the item. But this isn't always the case - for instance my advanced polls module has two quite different forms for creating a poll and modifying one.

    It depends on the module really as to how many templates are used; something like Pagesetter or postcalendar will have lots of templates others not so many e.g. the credits module only has three.

    How would you change the module architecture?

    Thanks for the feedback about the enhanced productivity of using pnRender - that's one of the many benefits we hope (and believe) pnRender provides. pnHTML - who needs pnHTML ;)

    -Mark

    --
    Visit My homepage and Zikula themes.
  • here's a list of the templates in the example mod:

    • plugins (dir)
    • index.html
    • example_admin_delete.htm
    • example_admin_main.htm
    • example_admin_menu.htm
    • example_admin_modify.htm
    • example_admin_modifyconfig.htm
    • example_admin_new.htm
    • example_admin_view.htm
    • example_block_first.htm
    • example_block_first_modify.htm
    • example_init_delete.htm
    • example_init_interactive.htm
    • example_init_step2.htm
    • example_init_step3.htm
    • example_init_upgrade.htm
    • example_user_display.htm
    • example_user_main.htm
    • example_user_menu.htm
    • example_user_row_overview.htm
    • example_user_row_read.htm
    • example_user_view.htm


    while I agree that it seems overwhelming at first and perhaps a bit excessive, you have to remember that this is an EXAMPLE module - intended to give an example of what is possible using pnRender et al.

    So - you have several admin templates - that match nicely with the admin functions that are within the module; several user templates (matches again); a couple blocks; and what appears to be new functionality in an interactive init process (maybe I just missed it).

    not every mod will use this many, but it is nice to have the example code for every possibility if needed.
  • doh! Mark beat me to the punch ;)
  • craigh

    what appears to be new functionality in an interactive init process (maybe I just missed it).


    New in .760rc3 I believe. It allows for a step by step installation process and was coded to allow more complex modules like pnphpbb to have a more standardised process for thier installation process.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • Lobos, I agree...it's like using a firehose where a water-balloon would suffice. ...I hope it doesn't end up like the language files situation...which is completely strung out of proportion... icon_rolleyes
  • markwest



    Thanks for the feedback about the enhanced productivity of using pnRender - that's one of the many benefits we hope (and believe) pnRender provides. pnHTML - who needs pnHTML ;)

    -Mark


    LOL I meant Smarty hehe, but I am sure pnrender does not differ too much :)

    in regards to module architecture, I don't really know what could be different, but it may be worth keeping an open mind - especially now that we have a new technology to exploit (pnrender). I am looking forward to this, but I am very slow to adopt new technology and at the moment I am still playing :)

    Oh just a heads up with the new inclusion of the h1, etc styles for titles and stuff - I am having a damn frustrating time with these in a project of mine, it seems they also come with a line height as well which can play havoc on complex layouts - I think i am also seeing a difference between our friends IE and FF...

    -Lobos

    --
    -Lobos
    Professional PHP Framework Services: Concept, Development and Deployment
  • On of the many differences that could be made on the mod creator side is to simply use a minimum of template but within these, having sections...


    Code

    <!--[if $func eq "view"]-->

      <!-- show this -->

    <!--[elseif $func eq "new"]-->

      <!-- show this -->

    <!--[else]-->

      <!-- show that -->

    <!--[/if]-->

    <!-- etc -->



    But in the end, that won't necessarily help the sanity of the dev.....
  • And would complicate things for the end user/themer trying to customize the layout.

    --
    Home Page | Find on Facebook | Follow on Twitter
  • Once your blown past templating confusion infinity, what's a bit more gonna hurt?
  • Personally, I find pnRender much easier than pnHTML, however I never used pnHTML much...

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • one reason why pnRender is better than pnHTML:

    a person who understands HTML can look at a pnRender template and understand what they are looking at. When that same person looks at pnHTML, they see PHP code - which they don't understand. sure - the HTML may be buried in the pnHTML, but in some cases, it is hard to find. Sure - the Smarty tags in a pnRender template confuse the matter a bit, but they don't have to worry about creating new tags or anything, just moving the content to where they want it.

    I've found pnRender MUCH better ther pnHTML - and I HAVE used both.
  • I was thinking a change in the way langauge is done could also be implemented with Smarty by using

    $smarty->config_load($_SERVER['DOCUMENT_ROOT'].'/modules/mymodule/lang/eng/user.lang');

    you can then have definitions like this:

    lang_title = "My Cool Module"
    lang_config = "Configure"

    etc, etc

    Looks a bit nicer than what we currently have (I know what I would rather be sending to the translators" LOL

    Acutally there is a good discussion about lang and Smarty here:

    http://www.phpinsider.com/smarty-forum/viewtopic.php?t=84

    Make sure you have some time on your hands - I liked the idea of using xml , but I am afraid that it is beyond my comprehension...

    -Lobos

    --
    -Lobos
    Professional PHP Framework Services: Concept, Development and Deployment
  • The easier defines are to send for translation the better. I know pnDefinemachine is around, but in some cases, that solution isn't feasible.

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • I have not seen your code specifically, but one thing I have noticed is that developers that do not really understand the point of templating misuse it. They seem to think that pnRender is simply a convenient set of functions and create templates much like the old non-templated system worked: lots and lots of actual logic happening in the template. In the more correctly templated modules, you find more templates because instead of using lots of loops, if/then's, etc in the templates, repeated sections of HTML in a module are split into seperate templates. I'm sure any templater would tell you that they certainly prefer more static templates even if it means more files to deal with.

This list is based on users active over the last 60 minutes.