Announcement

  •  » Engine
  •  » Custom page for plugin

#1 2013-01-16 18:29:25

flop25
Piwigo Team
2006-07-06
7037

Custom page for plugin

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

Code:

{$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

Code:

  $dir=dirname(__FILE__).'/user_tag.tpl';
  $template->set_filenames(array(
    'user_tag' => realpath($dir),
    )  );
  $template->assign_var_from_handle('CONTENT', 'user_tag');

To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#2 2013-01-16 18:44:33

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: Custom page for plugin

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

 

#3 2013-01-16 18:48:45

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: Custom page for plugin

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

 

#4 2013-01-16 18:49:20

flop25
Piwigo Team
2006-07-06
7037

Re: Custom page for plugin

I see what you mean : the plugin sets its own $page['body_id']


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#5 2013-01-19 17:41:01

flop25
Piwigo Team
2006-07-06
7037

Re: Custom page for plugin

This http://www.smarty.net/inheritance Could be great. An occasion to rewrite core files.


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#6 2013-01-29 20:13:23

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: Custom page for plugin

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

 

#7 2013-01-29 21:44:31

flop25
Piwigo Team
2006-07-06
7037

Re: Custom page for plugin

seems good
don't know if you noticed, in your diff it's 'empty_page.tpl'


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#8 2013-01-31 15:25:12

flop25
Piwigo Team
2006-07-06
7037

Re: Custom page for plugin

So should I go on or you take care what's next, like open a ticket etc?


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#9 2013-01-31 15:41:17

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: Custom page for plugin

I'll do, but can we add this in 2.5 ?

Offline

 

#10 2013-01-31 15:44:24

flop25
Piwigo Team
2006-07-06
7037

Re: Custom page for plugin

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


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#11 2013-01-31 17:18:01

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: Custom page for plugin

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

 

#12 2013-01-31 17:21:49

flop25
Piwigo Team
2006-07-06
7037

Re: Custom page for plugin

it can stay as this
then we could still change that by checking $page['section']


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#13 2013-01-31 17:28:19

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: Custom page for plugin

I... don't understand your first sentence :)

about checking $page['section']... not very reliable I think

Offline

 

#14 2013-01-31 20:43:44

rvelices
Former Piwigo Team
2005-12-29
1960

Re: Custom page for plugin

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

 

#15 2013-01-31 20:55:43

flop25
Piwigo Team
2006-07-06
7037

Re: Custom page for plugin

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


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 
  •  » Engine
  •  » Custom page for plugin

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact