Jump to content

gallery layout help


cerberus478

Recommended Posts

Hi I don't know if this is the right section but I would like to have my gallery open up in the content section. For example I have a page which has the gallery links on the navigation side and I want it to open in the content side. I have only been able to open it up in a new page. I'm using php to get the images.

 

Here is my default.php code:

 

<head>
<title><?php echo $this->get_title(); ?></title>
<meta name="Description" content="<?php echo $this->get_description(); ?>" />
<meta name="Keywords" content="<?php echo $this->get_keywords(); ?>" />
<title>Welcome to the Framework</title>
<?php
$this->_page->add_javascript('/vendor/lightbox/js/jquery.lightbox-0.5.min.js');
$this->_page->add_stylesheet('/vendor/lightbox/css/jquery.lightbox-0.5.css');
$this->_page->add_stylesheet('/css/default.css');

echo $this->page('stylesheets');
echo $this->page('javascripts');
?>

</head>

<body>


<div id="container">
<div id="banner">
	<h1>
	Welcome to the Grada djeri
	</h1>
</div>
<div id="nav">
<?php 
	echo $this->page('view');
?>



</div>
<div id="content">

	<?php  ?>
</div>



<div id="footer">
	<a href="/pages/about_me">About Me</a>
	<a href="/pages/contacts">Contacts</a>
	<a href="/pages/home">Home</a>
</div>
</div> 
</body>
</html>

 

 

and here is my home.php

 

<!-- <h2>This is the homepage</h2>-->




<?php 
//echo $this->_params['item']['content'];
// how to loop through an images and gallery name and put it into a list
foreach ($this->_params['list'] as $gallery ){
$gallery_name = $gallery['name'];
$image = $gallery['image'];

echo "<table>";
echo "<tr>";
echo "<td>";
echo "<a href=/galleries/view/".$gallery['id']."><img src='/image.php?path=$image&h=50&w=50'></a>";
echo "</td>";
echo "</tr>";
echo "</table>";
}

?>

Link to comment
Share on other sites

You don't need AJAX. That's not to say you can't use it, but I think it would be overkill for this. Make it work with a normal page load and you can always add AJAX loading later if you want.

 

Looking at the first script you have the "base" HTML file and nothing is being output inside the content DIV. You simply need to have your links reload the same page and pass a parameter on the query string so you can load the images. Give me a few minutes to review the code.

 

EDIT:

 

Hmm, I would have to see more of the code. But, that would take time to review. Simply have all your URLs point to your default page along with parameters on the URL so you can determine what content to create and display in the content div. E.g.

<a href="?action=load_gallery&id=15">Christmas Gallery</a>

 

Then in the default page, or an included() file, add a controller script to get the values from the GET var to determine what to do.

Link to comment
Share on other sites

My home.php which I gave already is the front page and it lists the gallery names and inside those gallery names is the pictures corresponding to that gallery.

 

This is the view.php which shows the pictures depending on the gallery that was chosen:

<h2><?php echo $this->_params['item']['name'] ?></h2>
<?php


if(!empty($this->_params['item']['gallery_images'])){

	foreach ($this->_params['item']['gallery_images'] as $gallery){
		$gallery_name = $gallery['name'];
		$image = $gallery['image_path'];
		$description = $gallery['description'];

		//echo $description;


			//echo "<img src=$image style=width:50px height:50px>";
			?>
<a href=<?php echo $image?> rel="lightbox" title="<?php echo $description ?>"><?php echo "<img src='/image.php?path=$image&h=50&w=50'>"?></a>

<?php  

	}

}	
?>

<script type="text/javascript">

$(function() {

$('a').lightBox({imageBtnClose: '/vendor/lightbox/images/lightbox-btn-close.gif',
				imageBtnPrev: '/vendor/lightbox/images/lightbox-btn-prev.gif',
				imageBtnNext: '/vendor/lightbox/images/lightbox-btn-next.gif',
				imageLoading: '/vendor/lightbox/images/lightbox-ico-loading.gif',
					});
});
</script>

 

This is the gallery_images controller:

<?php
class gallery_images_controller extends controller{
protected $_helpers = array('form', 'html');

public $model='gallery_images';

public function view($gallery_id){

	$this->_params['item'] = $this->_model->get($gallery_id);

	$this->_params['item'] ;
	//die;

}

}
?>

 

and this is the galleries controller

 

<?php
class galleries_controller extends controller{
protected $_helpers = array('form', 'html');

public $model='galleries';
public function galleries(){

	$galleries = $this->_model->get_all();


	$this->_params['list'] = $galleries;


}

public function view($gallery_id){

	$this->_params['item'] = $this->_model->get($gallery_id);

	$this->_params['item'] ;
	//die;

}

}
?>

 

I hope that helps

Link to comment
Share on other sites

What you need to is surround the image thumbnails with a hyperlink and ensure this link points to view.php and appends the image id:

 

<a href="view.php?imageid=30"><img src="/image/thumbnail30.jpg"/></a>

 

Then, when this link is clicked this calls the same page but now you can access the variable 'imageid' with $_GET.

 

$imagid = $_GET['imageid'];

//process logic dependent on value of imageid

 

Does this help?

Link to comment
Share on other sites

It didn't. I did try require('view/pages/home.php') and it kind of work but when I click the link and it goes to another page it gives me:

 

Notice: Undefined index: list in /var/websites/local.gradadjeri.com/view/pages/home.php on line 11 Warning: Invalid argument supplied for foreach() in /var/websites/local.gradadjeri.com/view/pages/home.php on line 11

Link to comment
Share on other sites

it should exist because it works fine in the home page but when I go to another page that's when I get the error. I get the $this->_params['list'] from my pages.controller.php which is this:

 

public function home(){
	//instantiate a model
	$galleries_model = new galleries_model('galleries');
	$galleries = $galleries_model -> get_all();


	foreach($galleries as $gallery){


		//how to loop through an image so that only the first
		//image is selected
		$sql = "SELECT image_path FROM gallery_images 
				WHERE 
						gallery_id = {$gallery['id']}
				ORDER BY order_by";

		$image = $this->_model->get_one($sql);

		$gallery['image'] = $image;
		$this->_params['list'][] = $gallery;

	}



Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.