Jump to content

apply fancybox only to one template


L. Leopold
 Share

Recommended Posts

Hi everyone,

I know the answer is right in front of me, but I've searched it for days already. I guess I'm still a beginner... please help me!

I'm using the multi-language site profile, suggested in the installation of processwire, if that helps.

I want to apply the fancybox only to the images of one template.

Fancybox is already running, I put the necessary code in the _main.php file.

     <link rel="stylesheet" href="<?php echo $config->urls->templates?>scripts/fancybox/source/jquery.fancybox.css" type="text/css" media="screen" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script type="text/javascript" src="<?php echo $config->urls->templates?>scripts/fancybox/source/jquery.fancybox.pack.js"></script>
    <script type="text/javascript">
	$(document).ready(function() {
		$(".gallery").fancybox({
  });
	});</script>

Therefore I created a new template php called "gallery.php" and put that code inside.

	   foreach($page->images as $image) {
	   $thumbnail = $image->size(150,100); 
echo "<a class='gallery' rel='gallery-1' href='{$image->url}' title ='{$thumbnail->description}'><img src='{$thumbnail->url}' style=' padding: 5px;' ></a>";
}

Now it shows the kind of gallery I want to have, but at the wrong possition of the site.

I just don't know what I have to write in there to change the position.

perhaps it is something like $content =...  , but I already tried every combination I could think of and I've looked at all the tutorials I could find.

I'm thankfull for any help,

Leo

Link to comment
Share on other sites

It seems like you are trying to use "delayed output" aproach as you are extending on a standart site-languages profile. You have to put all the html generated in gallery template in a $content variable for it to be rendered in the _main.php.

Like this:

foreach($page->images as $image) {
	$thumbnail = $image->size(150,100); 
	$content .= "<a class='gallery' rel='gallery-1' href='{$image->url}' title ='{$thumbnail->description}'><img src='{$thumbnail->url}' style=' padding: 5px;' ></a>";
}
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...