The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Photopost Pro Random Image Widget Details »» | |||||||||||||||||||||||||
Hey all,
One of the things that I missed from my transition from Drupal to vBCMS was my Photopost random image block. It's one of the features that my visitors seem to really like as well. After some trial and error, I managed to create a working vBCMS widget that utilizes the "Random Image Anywhere" code submitted by Garrynz on the Photopost site. Now, I will say that I am not a huge fan of the way that Garrynz's code works (variables are defined in the code rather than looking at the config files), but it's a quick and dirty way to get this work. In no way are your database details visible to anybody, so don't worry - it's more of an aesthetic thing than a security thing. Anyway, to utilize this widget, follow these steps: 1. Go into your AdminCP, vBulletin CMS, Widgets, and click on "Add New Widget" 2. Create a new widget of type "PHP Direct Execution" and name it what you want. This name gets used in the header of the widget. I chose "Random Image." 3. Paste the following code in, making changes for your specific environment: PHP Code:
You can see this widget in action on my site, http://www.njpinebarrens.com Show Your Support
|
Благодарность от: | ||
andro140 |
Comments |
#62
|
|||
|
|||
how can i let the output appear on new winprint "<div align=\"center\"><a href=\"photos/showphoto.php/photo/" . $row['id'] . "\"><img src=\"photos/data/" . $row['cat'] . "/thumbs/" . $row['bigimage'] . "\"></a><br /><a href=\"/gallery\">See more photos in the Gallery</a></div>"; dows, new frame.
|
#63
|
|||
|
|||
Just in case anyone needs it. I've modified the query to exclude a category I have for NSFW images. This was based on help from the photopost forums. Thought I would share.
Change Code:
$result = mysql_query("SELECT id,cat,bigimage FROM pp_photos order by rand() LIMIT 1" ) or die(mysql_error()); Code:
$result = mysql_query("SELECT id,cat,bigimage FROM pp_photos WHERE approved=1 AND cat NOT IN (502) order by rand() LIMIT 1" ) or die(mysql_error()); |
#64
|
|||
|
|||
hmm couldnt get this to show an actual picture - just the 'more pictures in the gallery' (the link of which worked ok)
shame |
#65
|
|||
|
|||
I have 4 images in a horizontal line
Is it possible to show images in vertical line rather than horizontal? |
#66
|
|||
|
|||
I have tried to change the div align code
and a few other things but I can't find the right way. |
#68
|
|||
|
|||
ZippySLC - thanks for such a nice little hack works as described no problems
couple of things 1) i have found that i can increase the number of images shown by changing LIMIT to a higher number this is great but i would love to have the images shown horizontally - is this possible ?? 2) i also tried changing the order from random to date but strangely it showed it in the reverse order with the oldest images in the database showing first - regards and thnx again Anthony |
#69
|
|||
|
|||
If you are usign SEO in "Spider-Friendly URL's" you have to change the Select and the href code:
Code:
SELECT p.id,p.user,p.userid,p.cat,p.bigimage,p.title,c.catname,c.photos,c.posts FROM pp_photos p LEFT JOIN pp_categories c ON c.id = p.cat WHERE p.storecat = 0 AND p.cat NOT IN (500) ORDER BY RAND() LIMIT 1 Code:
print "<div align=\"center\"> <a href=\"gallery_url/g" . $row['cat'] . "-" . $row['catname'] . ".html\"> <img ... It works in my site about aquariums |
#70
|
|||
|
|||
Hi,
I am a newbie and want to use your widget. I have followed the steps as mentioned by you but i don't have Photopost tables. From where i can get this tables. Please help me on this. Regards, Pankaj |
#71
|
|||
|
|||
I was messing around with this code today and was able to get the widget to show HORIZONTALLY. Here is what I got and if you want to see it in action, visit http://www.modificationnation.com/ and under the big banner in the center you will see random members then FRESH INK & MODS.
You will need to add your database info at the top and change DOMAIN.COM to your URL. It should work no matter what your seo url's are set to but I don't know for sure. I have it set up to pull the newest photos from the gallery. If you would like it to pull random simply change "order by id DESC" to "order by rand()" I am no coder, so I will do my absolute best to help you if it doesn't work Code:
$host = 'localhost'; $dbUser = 'DATABASE USER'; $dbPass = 'DATABASE PASSWORD'; $db = 'DATABASE NAME'; mysql_connect("$host", "$dbUser", "$dbPass") or die(mysql_error()); mysql_select_db("$db") or die(mysql_error()); ob_start(); $result = mysql_query("SELECT id,cat,bigimage FROM pp_photos order by id DESC LIMIT 8") or die(mysql_error()); print "<table align=\"center\" border=\"3\" bordercolor=\"black\" cellpadding=\"10\"><tr>"; while($row = mysql_fetch_array( $result )) { print "<td><div align=\"center\"><a href=\"http://DOMAIN.COM/showphoto.php/photo/" . $row['id'] . "\"><img src=\"http://DOMAIN.COM/data/" . $row['cat'] . "/thumbs/" . $row['bigimage'] . "\" width=\"100px\" height=\"100px\"></a></div></td>"; } print "</tr></table>"; $output .= ob_get_contents(); ob_end_clean(); |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|