following http://fr.piwigo.org/forum/viewtopic.ph … 74#p198074
$template->set_filename('index', .....); -> can you use another name than "index". Or plugin could use the default index then prefilter it.
A cleaned index.tpl -called page.tpl for ex- would be set like the others $template->set_filename('custom_page', .....); by plugins and would contain only something like
{$MENUBAR} {if isset($errors) or isset($infos)} <div class="content messages{if isset($MENUBAR)} contentWithMenu{/if}"> {include file='infos_errors.tpl'} </div> {/if} {if !empty($PLUGIN_INDEX_CONTENT_BEFORE)}{$PLUGIN_INDEX_CONTENT_BEFORE}{/if} <div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}"> <div class="titrePage"> <ul class="categoryActions"> {if !empty($PLUGIN_INDEX_ACTIONS)}{$PLUGIN_INDEX_ACTIONS}{/if} </ul> <h2>{$TITLE}</h2> </div>{* <!-- titrePage --> *} {if !empty($CONTENT)} <div class="additional_info"> {$CONTENT} </div> {/if} {if !empty($PLUGIN_INDEX_CONTENT_END)}{$PLUGIN_INDEX_CONTENT_END}{/if} </div>{* <!-- content --> *} {if !empty($PLUGIN_INDEX_CONTENT_AFTER)}{$PLUGIN_INDEX_CONTENT_AFTER}{/if}
where content could be any tpl file parsed like
$dir=dirname(__FILE__).'/user_tag.tpl'; $template->set_filenames(array( 'user_tag' => realpath($dir), ) ); $template->assign_var_from_handle('CONTENT', 'user_tag');
Offline
I agree with that, to only problem is : how and where do we decide to load "custom_page" instead of "index" in index.php ?
Offline
additionnaly I think some enhancement can be done here : if we find a way to detect that we are in a "custom page" we can skip lines 44 to 333 (with some ajustements) of index.php because they are useless
Offline
I see what you mean : the plugin sets its own $page['body_id']
Offline
This http://www.smarty.net/inheritance Could be great. An occasion to rewrite core files.
Offline
here is what I tested
http://pastebin.com/Jd5f7kwx
how it works : if a plugin define $page['body_id'] within the trigger "loc_end_section_init" we assume that we are not in the core index, so lines 123 to 334 are not executed, instead we load "common_page.tpl" as default "index" template
I had to move include('menubar.inc.php') away ; I need to check this, it works but I know there are some optimisations on categories list, perhaps they are broken now
now for a plugin :
- an event handler on "loc_end_section_init", defining $page['section'], $page['title'] and $page['body_id']
- an event handler on "loc_end_index" include the main plugin script, in this script we use "assign_var_from_handle" as flop25 suggested
bonus: : it's retro-compatible
Offline
seems good
don't know if you noticed, in your diff it's 'empty_page.tpl'
Offline
So should I go on or you take care what's next, like open a ticket etc?
Offline
I'll do, but can we add this in 2.5 ?
Offline
I can do the tpl file to discharge you/speed up
I don't know what plg plained, but that's a RC1 so we can still improve it between each RC
Offline
actually I wonder if if (!isset($page['body_id'])) is really good...
for example if later we want different body_id for the search results page or calendar page we gonna have a bad time :-)
so why not $page['is_external'] as we already have $page['is_homepage'] ?
Offline
it can stay as this
then we could still change that by checking $page['section']
Offline
I... don't understand your first sentence :)
about checking $page['section']... not very reliable I think
Offline
check wordpress
<body class="home blog">
<body class="home blog paged paged-2">
<body class="single single-post postid-121 single-format-standard">
<body class="single single-post postid-14 single-format-standard single-author singular two-column right-sidebar">
<body class="archive category category-7">
<body class="archive tag tag-16">
<body class="archive date">
<body class="page page-id-31 page-template-default">
<body class="login login-action-register wp-core-ui">
<body class="login login-action-lostpassword wp-core-ui">
maybe we can get something from here ...
Offline
Yes the body id should be much better like WordPress. For me that's the second step
My vision is the page section is the way for Piwigo and plugin to understand what's the current page, clearly and simply. Page body id is well.. just to set the id of the body for the theme
Offline