tags for dynamic pages

I have taken over my website written by others, it is in php and the gallery is dynamicly generated with thumb nails of other galleries, I would like to add unique tags to each sub gallery, however the main gallery gets its tags before the code calls for the creation of the sub gallery. is there a way round this? I can post the code here if you beleive there is a way to do it.

Thanks in advance for any help.

Hi Jel,

If your gallery is generated dynamically, there must be some back-end with database, admin panel etc.?
If so, it is likely that along with php code modifications, you will need to modify database - add new fields for subgallery tag.

Please post here your php code that generates gallery.

As far as I know the images are kept in a directory and the page calls up a list of sub directories, which each of the galleries are held in, and the same again when the sub galleries are displayed, to create the thumb display for each gallery.

if this makes sense, sorry i’m a carpenter only been getting to grips with this for two days.

I think this is the bit that loads the gallery.


//=================================================COPY THIS BIT TO gallery.php. BE SURE TO PUT IT IN THE SAME PLACE ON THE PAGE
//get the text file from the gallery
echo $description;

//=============================================END OF BIT TO COPY================================================================

//display the photos

echo “<a class=“thumbnail” href=”/gallery.php"><img src="./siteimages/back.jpg"width=“100px” height=“66px” border=“0” alt=“Back to gallery Home” title=“Return to gallery home”>";

// Get all the filenames from the gallery_images folder and display them.
// Define the full path to the gallery folder.
$path = "$dir";
// Open the folder
$dir_handle = @opendir($dir) or die("Unable to open $_POST[dir]");
// Loop through the files
while ($file = readdir($dir_handle)) {
if($file == "." || $file == ".." || $file == "index.php" || strpos($file, "txt") ) //COPY THE LAST BIT OF THIS LINE TOO "|| strpos($file, "txt")"
//Set a counter to populate line_brk with <br> every two lines.
    $lin = ($lin + 1);
    if($lin == 2){$lin = 0; $line_brk = "<br>";}else{$line_brk="";}
//output the code line by line for each picture in the folder.

echo “<a class=“thumbnail” href=”#thumb"><img src="$dir/$file"width=“100px” height=“66px” border=“0"alt=”$altText" title="$titleText"><img src="$dir$file"alt="$altText" title="$titleText">$l
// Close the folder

Well, so sub-gallery description is populated from txt file within the images directory. Also alt and title attributes for each image are also stored in txt files within images directory. But I can’t see where is the code that generate the main gallery (there must be links to sub-galleries).

The link are created by the thumbnails in the main gallery view. here is the code from the main page.

I have just added the alt and text files try and get listed better on google, hence trying to get the header tags correct and not all the same, this bit I am lost on though,

         <style type="text/css">

            echo $style;
//SuckerTree Vertical Menu 1.1 (Nov 8th, 06) //By Dynamic Drive: http://www.dynamicdrive.com/style/ var menuids=["suckertree1"] //Enter id(s) of SuckerTree UL menus, separated by commas function buildsubmenus(){ for (var i=0; i<menuids.length; i++){ var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul") for (var t=0; t-1; t--){ //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars ultags[t].style.visibility="visible" ultags[t].style.display="none" } } } if (window.addEventListener) window.addEventListener("load", buildsubmenus, false) else if (window.attachEvent) window.attachEvent("onload", buildsubmenus) [/i]

This last piece of code you posted - is javascript, not php. It is still not clear what do you want to customize in this code. If you want to have custom header on each sub-gallery, you can do this similar to how it is done for descriptions - create txt file with header in each sub-gallery’s directory, and then populate this header from text file to sub-gallery page.

at the moment all the galleries have the same title and description meta tags, hence I have 12 galleries all titled the same, I would like to get them all to be related to their content, so can I store meta data in a txt file that the page reads on loading along with the associated images in each folder.

Based on the code what you posted above, you can add the following lines to your gallery_display.php script (insert these lines in between the opening tag and :


<?php $meta_title=file_get_contents($dir.'meta_title.txt'); $meta_keywords=file_get_contents($dir.'meta_keywords.txt'); $meta_description=file_get_contents($dir.'meta_description.txt'); ?>


Then, modify your html title tag, to populate content from file:
<?php echo $meta_title ?>

Same with keywords and description tags:


And finally, create these text files and put them in each of your subgallery directory:


Spot on, worked a treat.

Many Thanks.


Sponsor our Newsletter | Privacy Policy | Terms of Service