Jump to content

Switching From Javascript to PHP- generating a list of items


shauniqua

Recommended Posts

Please see: http://www.davidsongalleries.com/artists/moreau/moreau.php

 

The images and their corresponding texts are generated using this short script:

 

function artinfo(file,artist,linked,medium,size,price,box) {
stats = '<li>\<a href="' + file + '" title="' + artist + '. ' + linked + '. ' + medium + '. ' + size + '. ' + price + '" class="thickbox" rel="' + box + '" onfocus="this.blur();"><img src="th/' + file + '" alt="-thumbnail-" /><br />' + linked + '\</a><br />' + medium + '.<br />' + size + '.<br /><span class="price">' + price + '\</span>\</li>';
document.write(stats);
}

 

...and called like so:

 

artinfo('moreau-awaken_to_terror.jpg','Ben Moreau','Awaken to the Terror of a New Day, 2007','Photopolymer Gravure. Edition of 6','30 x 22 inches','$550','moreau');

 

I set it up this way to avoid pasting in the same information  repeatedly into the two views on the page (using a Thickbox window along with duplicate static page text). There are several hundred pages like this on the site, but each is handled a little differently, so a database was not the best solution.

 

However, using this script, the images and their texts are, of course, not found by search engines. Moreover, they cannot be read by "share" links via Facebook, et al.

 

Ideally, I'd like to be able to create a similar call with PHP, but I'm a total beginner and can't seem to make it work. Is this possible? How would I go about it?

this should do it

<?php
function artinfo($file, $artist, $linked, $medium, $size, $price, $box)
{
$stats = '<li><a href="' . $file . '" title="' . $artist . '. ' . $linked . '. ' . $medium . '. ' . $size . '. ' . $price;
$stats .= '" class="thickbox" rel="' . $box . '" onfocus="this.blur();">';
$stats .= '<img src="th/' . $file . '" alt="-thumbnail-" />';
$stats .= '<br />' . $linked . '\</a><br />' . $medium . '.<br />' . $size . '.<br /><span class="price">' . $price . '\</span>\</li>';
echo $stats;
}
?>

i broke it up and you call call it just the same but it just needs to be inside <?php ?> tags

 

Scott.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.