cerberus478 Posted October 12, 2011 Share Posted October 12, 2011 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>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/248959-gallery-layout-help/ Share on other sites More sharing options...
titan21 Posted October 12, 2011 Share Posted October 12, 2011 I'm thinking that you need to look at an AJAX solution to this possibly? Quote Link to comment https://forums.phpfreaks.com/topic/248959-gallery-layout-help/#findComment-1278737 Share on other sites More sharing options...
Psycho Posted October 12, 2011 Share Posted October 12, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/248959-gallery-layout-help/#findComment-1278742 Share on other sites More sharing options...
cerberus478 Posted October 13, 2011 Author Share Posted October 13, 2011 @Titan21 How would I be able to use ajax. I have never used it so I wouldn't know how to put that into my website. @mjdamato can you give me a better example please Quote Link to comment https://forums.phpfreaks.com/topic/248959-gallery-layout-help/#findComment-1278876 Share on other sites More sharing options...
titan21 Posted October 13, 2011 Share Posted October 13, 2011 mjdamato is probably right. Best to get it working normally. Once you've grasped that, you should be able to implement an AJAX solution - we'd need to see more of your code though to give you good guidance on how to implement this. Ca you upload your files? Quote Link to comment https://forums.phpfreaks.com/topic/248959-gallery-layout-help/#findComment-1278881 Share on other sites More sharing options...
cerberus478 Posted October 13, 2011 Author Share Posted October 13, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/248959-gallery-layout-help/#findComment-1278890 Share on other sites More sharing options...
titan21 Posted October 13, 2011 Share Posted October 13, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/248959-gallery-layout-help/#findComment-1279052 Share on other sites More sharing options...
cerberus478 Posted October 14, 2011 Author Share Posted October 14, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/248959-gallery-layout-help/#findComment-1279243 Share on other sites More sharing options...
titan21 Posted October 14, 2011 Share Posted October 14, 2011 That basically means that your trying to access a member of an array that doesn't exist. Make sure you're setting it before calling it. Quote Link to comment https://forums.phpfreaks.com/topic/248959-gallery-layout-help/#findComment-1279247 Share on other sites More sharing options...
cerberus478 Posted October 14, 2011 Author Share Posted October 14, 2011 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; } Quote Link to comment https://forums.phpfreaks.com/topic/248959-gallery-layout-help/#findComment-1279249 Share on other sites More sharing options...
cerberus478 Posted October 14, 2011 Author Share Posted October 14, 2011 @titan21 I managed to fix the problem. I had to make a copy of my public function home to all the other controllers. Thank you for helping me Quote Link to comment https://forums.phpfreaks.com/topic/248959-gallery-layout-help/#findComment-1279279 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.