Announcement

#1 2012-09-14 13:24:40

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

[Tip] dynamic additional page content

from [Forum, topic 20324] A Page specific to an album

IGraham wrote:

Hi Mistic
I've emailed you because this might be a little difficult to explain and if its not possible will only clutter the forum - if it is possible I'll create a post as it might be useful to others
This isn't directly a 'Linked Pages' thing though I think could only be used with

To avoid having to create loads of pages in the pages extension (just one)
In the one created page, would it be possible to dynamically pick up the address of the album instance and use it in an Iframe to point at an external page ?
I'd Create a folder structure (year/album) containing html pages specific to a album
2012/
     Album1/page.html
     Album 2/page.html
     Album 3/page.html

Hopefully you'll understand what I mean

this could be achieved by modifying Additional Pages, we also can do it in pure Javascript
this way we CAN'T know the storage folder of the album, only it's ID

so I wrote this piece of code, which extracts album ID from referrer URL, and change iframe source and Return button

Code:

<script type="text/javascript">
var folder = "pages/";
var album = "index.php?/category/";

function isInt(x) {
  var y=parseInt(x);
  if (isNaN(y)) return false;
  return x==y && x.toString()==y.toString();
}

jQuery(document).ready(function() {
  url = document.referrer.split('&');
  url = url[0].split('/');
  url = url[ url.length -1 ];

  $("#linked_pages:not(.new)").remove();
  
  if (isInt(url)) {
    $("#target").attr("src", folder+url+".htm");
    $("#linked_pages li a").attr('href', album+url);
  }
});
    
</script>

<ul id="linked_pages" class="new">
  <li id="linked_page_0" class="row_0"><a href="">Return</a></li>
</ul>

<iframe id="target" src="" style="border:none;width:100%;height:600px"/>

to use it
- create an additional page with this content
- create a "pages" folder in the root of Piwigo installation containing one htm file for each album (1.htm, 25.htm, 89.htm)
- link this Additional Page to all needed albums using Linked Pages plugin
- that's all !

note: if nothing append it might be because jQuery is not loaded, so add this at the begining of the page

Code:

<script type="text/javascript" src="themes/default/js/jquery.min.js"></script>

important: this will not work if you use $conf['question_mark_in_url'] = false; but I think this can be solved by changing variables like this

Code:

var folder = "../../pages/"; // might change the number of "../"
var album = "index.php/category/"; // not sure too

Last edited by mistic100 (2012-09-14 16:45:11)

Offline

 

#2 2012-09-14 14:34:56

IGraham
Member
UK
2011-09-28
193

Re: [Tip] dynamic additional page content

Mistic
There are days when I just gawp in amazement and realise my own inadequacy
A wish I could barely put into words is returned as a solved with in a few hours
Do you by any chance do this for a living

It'll probably take me longer to implement than it did for you to create

Thanks for doing it

Offline

 

#3 2012-09-14 16:17:41

IGraham
Member
UK
2011-09-28
193

Re: [Tip] dynamic additional page content

so far not working, in the actual gallery i get the album name field and below that a 'retun' field
i've tried tweeking the 'pages' folder path - no difference
i've tried putting the 'pages folder in different levels - no difference
the 'id' (9) i picked up from the Album properties page 'Numeric identifier : 9'

any idears

Offline

 

#4 2012-09-14 16:26:23

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

Re: [Tip] dynamic additional page content

do you have an example of album using this system ?

Offline

 

#5 2012-09-14 16:34:10

IGraham
Member
UK
2011-09-28
193

Re: [Tip] dynamic additional page content

http://sunderlandmountaineeringclub.org … category/3

look at 'Carlisle Hut - June'
do you want me to create a admin account for you

Offline

 

#6 2012-09-14 16:44:00

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

Re: [Tip] dynamic additional page content

oh ok, I used jQuery assuming it's activated on all galleries, but this is not the case

add this in the begining of the page

Code:

<script type="text/javascript" src="themes/default/js/jquery.min.js"></script>

(sadly I don't really know to code without jQuery)

Offline

 

#7 2012-09-14 16:53:29

IGraham
Member
UK
2011-09-28
193

Re: [Tip] dynamic additional page content

yes that worked
thanks

Offline

 

#8 2012-09-26 11:02:14

IGraham
Member
UK
2011-09-28
193

Re: [Tip] dynamic additional page content

Hello Mistic

The Linked Pages extension and the redirect to a iframe are working well - I'm most pleased
Again thanks

http://sunderlandmountaineeringclub.org … o2/piwigo/

One thing, that may or not be fixable, if its not then to bad
Go to any of the albums and click the link field 'the write up' top left above the images
For a second or two just before the page loads successfully every page I've created is shown in a small field - I'm assuming all the created pages are what's being shown ?

Any idea if this can be fixed

Offline

 

#9 2012-09-26 12:41:51

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

Re: [Tip] dynamic additional page content

that's because the javascript waits for the complete load of the page

you can try to remove the jQuery(document).ready(function() { wrapper (and the last });) but this could induces strange behaviors

Offline

 

#10 2012-09-26 15:42:23

IGraham
Member
UK
2011-09-28
193

Re: [Tip] dynamic additional page content

thanks for the effort unfortunately didn't work
i can limit the effect by in the 'pages extension' creating a page for each year so only the that years will stuff will briefly appear
? wonder if i can hide that bit of unwanted action behind a layer ?

Offline

 

#11 2012-09-26 15:58:18

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

Re: [Tip] dynamic additional page content

<style type="text/css">
#linked_pages:not(.new) {
  display:none;
}
</style>

does this work ?

Offline

 

#12 2012-09-26 16:31:40

IGraham
Member
UK
2011-09-28
193

Re: [Tip] dynamic additional page content

where about in the script would i put that - I've done a bit of c++ and a bit java but that was a few years ago

-----

<script type="text/javascript" src="themes/default/js/jquery.min.js"></script><script type="text/javascript">
var folder = "pages/";
var album = "index.php?/category/";

function isInt(x) {
  var y=parseInt(x);
  if (isNaN(y)) return false;
  return x==y && x.toString()==y.toString();
}

jQuery(document).ready(function() {
  url = document.referrer.split('&');
  url = url[0].split('/');
  url = url[ url.length -1 ];

  $("#linked_pages:not(.new)").remove();
 
  if (isInt(url)) {
    $("#target").attr("src", folder+url+".htm");
    $("#linked_pages li a").attr('href', album+url);
  }
});
   
</script>
<ul class="new" id="linked_pages">
    <li class="row_0" id="linked_page_0">
        <a href="">Return</a></li>
</ul>
<p>
    <iframe id="target" src="" style="border:none;width:100%;height:600px"></iframe></p>

Offline

 

#13 2012-09-26 18:11:02

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

Re: [Tip] dynamic additional page content

could be about everywhere, usually at the very begining or the very end

Offline

 

#14 2012-09-26 22:45:56

IGraham
Member
UK
2011-09-28
193

Re: [Tip] dynamic additional page content

good man
yes that did work
but only if i put it at the end

it works I'm happy

thanks

Offline

 

Board footer

Powered by FluxBB

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