Pages (2): 1 2   
Member
Member
vincent3569   17-10-2017, 09:14
#1

hi

several themes uses gallery.php as index page for their gallery (as offical zenpage and garland themes).

rewriteToken plugin allows to change some rewrited url.
but it doesn't allow to rewrite gallery url and it remains page/gallery

if you think it's a good idea, could you update this plugin to enable a token to change gallery url as needed?

Administrator
Administrator
acrylian   17-10-2017, 09:49
#2

The reason there is no rewrite token is that this is a plain custom page ulr (in theme terms).

We will probably not add anything for it at this time as we have other ideas for this page going on. Since there is a mismatch in url structure if this is the base gallery url in relation to album pages anyway. It may be decoupled from the custom page url just like Zenpage pages are in the future. Then there will be surely a way to define its name.

Member
Member
sbillard   17-10-2017, 14:12
#3
/*
* creates a rewrite rule for "page/gallery" and modifies the link to same to
* follow the rule.
*
* @author Stephen Billard (sbillard)
*/

$plugin_is_filter = 5 | FEATURE_PLUGIN;
$plugin_description = gettext('Rewrite rule for the gallery custom page.');
$plugin_author = "Stephen Billard (sbillard)";

$_zp_conf_vars['special_pages']['gallery'] = array('define' => '_GALLERY_PAGE_', 'rewrite' => getOption('galleryToken_link'),
'option' => 'galleryToken_link', 'default' => '_PAGE_/gallery');
$_zp_conf_vars['special_pages'][] = array('definition' => '%GALLERY_PAGE%', 'rewrite' => '_GALLERY_PAGE_');

$_zp_conf_vars['special_pages'][] = array('define' => false, 'rewrite' => '%GALLERY_PAGE%', 'rule' => '^%REWRITE%/*$ index.php?p=' . 'gallery' . ' [L,QSA]');
Member
Member
vincent3569   17-10-2017, 17:27
#4

thanks Stephen.

my final plugin is as following:

Member
Member
vincent3569   17-10-2017, 17:34
#5

but it doesn't work.

I have this in my admin:

Rewrite Rules
#### Definitions
[...] 
Define %GALLERY_PAGE%       gallery 

and

 #### Rules created by plugins
[...] 
rewriterule ^gallery/*$     index.php?p=gallery [L,QSA]

and

Rewrite Tokens
[...] 
_GALLERY_PAGE_          gallery 

but the rewrited url remains [domain_name]/page/gallery/

Member
Member
sbillard   17-10-2017, 17:52
#6

How are you creating the url?

Member
Member
vincent3569   17-10-2017, 18:17
#7

I suppose it is linked with this function getGalleryIndexURL().
there is this code:

    [...]
    $custom_index = getOption('custom_index_page');
    if ($custom_index) {
        $link = rewrite_path('/' . _PAGE_ . '/' . $custom_index . '/', "/index.php?p=" . $custom_index);
    } else {
        $link = WEBPATH . "/";
    }
    [...]

I really don't know if it follows the internal rewrite engine of Zenphoto and if rewrite token may be applied in that case.

Member
Member
sbillard   17-10-2017, 18:44
#8

Yes, that function does not do the rewrite rules. You should use the function getCustomPageURL() instead.

Really, the getGalleryIndexURL() function should only return the index.php page. Themes should know if they are having a "gallery" page for the albums and act accordingly using getCustomPageURL('gallery') for the link. That is how it is with ZenPhoto20. Much less prone to error.

Member
Member
vincent3569   17-10-2017, 19:46
#9

something goes wrong somewhere...
I use printCustomPageURL(gettext('Gallery'), 'gallery'); in my theme, but it doesn't display the rewrited link.

I add var_dump($_zp_conf_vars['special_pages']['gallery']); in my header and it return NULL.

so it seems that plugin doesn't add values to $_zp_conf_vars['special_pages']

and in the other hand, in this template function

function getCustomPageURL($page, $q = '') {
    global $_zp_current_album, $_zp_conf_vars;
    if (array_key_exists($page, $_zp_conf_vars['special_pages'])) {
        $result_r = preg_replace('~^_PAGE_/~', _PAGE_ . '/', $_zp_conf_vars['special_pages'][$page]['rewrite']) . '/';
    } else {
        $result_r = '/' . _PAGE_ . '/' . $page . '/';
    }

we are allways in the else statement.

Member
Member
sbillard   17-10-2017, 21:41
#10

Are you sure the galleryToken plugin is enabled? Sure sounds like it is not. Also check the rewriteTokens plugin options to be sure that "gallery" is shown and has a value.

I think also that the script above has an error. Probably should read $plugin_is_filter=5|CLASS_PLUGIN; to be sure it is loaded on the front end.

Member
Member
sbillard   17-10-2017, 22:19
#11

actually, the line should be as I originally quoted it: $plugin_is_filter=5|ADMIN_PLUGIN; but CLASS_PLUGIN should work as well.

Member
Member
sbillard   17-10-2017, 22:20
#12

Woops. forgot to check the text paste. Should be $plugin_is_filter=5|FEATURE_PLUGIN;

Member
Member
vincent3569   18-10-2017, 06:57
#13

yes, galleryToken plugin is enabled.

I change $plugin_is_filter as described and it works now.
But I have a new trouble: get/printCustomPageURL() doesn't manage page number for gallery pages.

Administrator
Administrator
acrylian   18-10-2017, 08:12
#14

Actually it has a second parameter to append extra queries such as the page number. That should be something like &page= actually.

Btw, we have some plans with the gallery page that will also involve changes to the "galleryindex" page handling in the future.

Member
Member
vincent3569   18-10-2017, 09:55
#15

yes of course.

the fact is that getGalleryIndexURL() displays the page number organically, while with get/printCustomPageURL(), we have to calculate it before we call the function.

I will be patient and I will waiting for the major release...

Administrator
Administrator
acrylian   18-10-2017, 10:19
#16

Internally getGalleryIndexURL() just does this:
if (in_context(ZP_ALBUM) && $_zp_gallery_page != 'index.php') { $album = getUrAlbum($_zp_current_album); if (($page = $album->getGalleryPage()) > 1) { } }

It also would use a custom index page if the the option custom_index_page is set.

We have some term issues since normally "gallery" means the Zenphoto site in total so by default the home page isthe gallery index (= top level albums). Using a gallery page it is not or you even have two "gallery index" pages depending on the theme used.

Thanks for the patience though. I would love it to happen faster.

Member
Member
sbillard   19-10-2017, 00:52
#17

I am a little confused here. Can you explain more on how you are using this? Normally the getGalleryIndexURL() and getCustomPageURL() are used when you are NOT on the target page. If that is the case how do you determine which page of the gallery the link should point to?

If you are on the albums pages then the breadcrumbs functions should give you the correct (rewritten) links to other pages within the "gallery." However, that seems not the case. So a bug in those functions?

Member
Member
vincent3569   19-10-2017, 09:01
#18

hi

have a look on zenpage theme.
in gallery.php, album.php and image.php, breadcrumb uses printGalleryIndexURL(), and in sidebar.php, the link to the gallery uses printCustomPageURL().

if you have a gallery with more than one page, and your are on an album of the 2nd page, the gallery link in the breadcrumb gives you this url page/gallery/2/ and the gallery link in the sidebar gives you page/gallery/.

for me it's OK because in the breadcrumb, I want to know on witch page I am (and go back to the right gallery page) and in sidebar, I don't want pagination (I only want to point to the root of the gallery).

BUT, the printGalleryIndexURL() link can't be rewrited contrary to printGalleryIndexURL().

Administrator
Administrator
acrylian   19-10-2017, 09:12
#19

This function allows any page to be the index page. It simply does not know which page it is going to use until it gets the name set via the "custom_index_page" option which usees the page name and does not know about any rewriting. This is in this case "gallery".

To rewrite this you need to hook into the getLink filter and modify the link there. That's called after the link is generated within that function.

Member
Member
vincent3569   19-10-2017, 14:11
#20

unfortunatly, I don't understand nothing :-(
you have to be more clear within an example

Pages (2): 1 2   
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.