how display the last zenphoto video in the index

hi all, i'd like to display in the index the last zenphoto video.
zenphoto is installed in /zenphoto and the index i'm talking is up of one dir to zenphoto dir. Is it possible?
«1

Comments

  • hi acrylian, thanx for your support.i'm not expert with php.
    I understand that i should insert in the page zp connections...
    should be this:
    <?php if (!defined('WEBPATH')) die(); $themeResult = getTheme($zenCSS, $themeColor, 'light'); $firstPageImages = normalizeColumns('2', '6');?>
    then the player js
    <script type="text/javascript" src="/video/zp-core/js/flvplayer.js"></script>

    and then the video and player code
    " title="<?php echo getImageTitle();?>"><?php printDefaultSizedImage(getImageTitle()); ?>
    but how should i modify it to take the last video (by date)?
    i saw the template functions, but i don't know what to do.
  • acrylian Administrator, Developer
    You don't need to change those parts you posted. The player is already in zenphoto, no need to call it directly. Zenphoto currently supports Flash Video (.flv), Quicktime (.mov) and 3GP (.3gp). zenphoto is not able to generate a thumbnail of a video, you have to do that manually: http://www.zenphoto.org/support/topic.php?id=2022&replies=3.

    The printLastestImages functions prints thumbnails of the latest uploade images. It does not make any difference between images and movies. Just place `<?php printLatestImages(5); ?>` where on your theme page you want to show the latest images (works on index, image and album.php). Example is for 5 latest images, additionally you can add the name of a specific album you want them from like this `<?php printLatestImages(5, "album xy"); ?>`)
  • Thanks again acrylian, i know that zenphoto supports flv mov and 3gp, i'd like to display the latest video in another page that isn't in the zenphoto directory.
    Ex.
    tha page is
    /index.php
    zenphoto is in a subdirectory installed in
    /zenphoto/
    i'd like to take the last video and display it, with zenphoto player directly in index.php
    thank you:)
  • acrylian Administrator, Developer
    Sorry, I just overread that detail with the index.php! Probably this could be helpful for you: http://www.zenphoto.org/2008/01/hacks/#zenphoto-as-plugin

    I don't know of a way to have the flv player directly on index.php and taking care of the latest stuff from zp. But I haven't tried or thought about that. You probably will have to add that player and the movie manually (which comes from here by the way: http://www.jeroenwijering.com/?item=JW_FLV_Media_Player) to your site.
  • don't worry acrylian.
    i had a fast look to the link you posted.
    Tomorrow i'll try again, the player displays ok, need the php code to get the last video.
    thank's for your help!!
  • you can put this code on your index.php

    it will show the latest 5 videos;

    `<?php <br />
    $images = getImageStatistic($_zp_gallery->getNumImages(), "latest");

    $x = 1;

    foreach ($images as $image) {

    if (is_null($image->getVideoThumb())){$x=$x-1;}else{

    echo "imagegetThumb()."">";

    }

    if ($x++ >=5) {

    break;

    }

    }?>`

    and if it is not on your zenphoto index off course follow the zenphoto as a plugin guide
  • Hi BertSimons!
    On a fast look I added this
    define('ZENFOLDER', 'zp-core');
    define('WEBPATH', 'zenphoto');
    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");
    to enable zp functions, it works.
    the code you sent is not working, i corrected it to echo "<img src=\"".$image->getThumb()."\">";
    it displays the last video thumbnails.
    I don't know if i should also insert the a href to $image.
    I will try later and i will inform you.
    Many thanks
  • code with link, sorry for the bad paste earlier, checked this one

    `<?php <br />
    $images = getImageStatistic($_zp_gallery->getNumImages(), "latest");

    $x = 1;

    foreach ($images as $image) {

    if (is_null($image->getVideoThumb())){$x=$x-1;}else{

    $imageURL = getURL($image);

    echo "imagegetThumb()."\">";

    }

    if ($x++ >=5) {

    break;

    }

    }?>`
  • Hi BertSimons, i'm near the solution now!!!
    I'm tryng now to display directly the video in the player (the code you send display the thumbnail and the link).
    I'm working on this
    [code]<div id="image">
    <p id="player">
    <?php
    $images = getImageStatistic($_zp_gallery->getNumImages(), "latest");
    $x = 1;
    foreach ($images as $image) {
    if (is_null($image->getVideoThumb())){$x=$x-1;}else{
    $imageURL = getURL($image);
    echo "<script type=\"text/javascript\">";
    echo "var so = new SWFObject(\"/video/zp-core/flvplayer.swf\",\"player\",\"320\",\"240\",\"7\");";
    echo "so.addParam(\"allowfullscreen\",\"true\");";
    echo "so.addVariable(\"file\",\"".$imageURL ."\");";
    echo "so.addVariable(\"displayheight\",\"310\");";
    echo "so.write(\"player\");";
    echo "</script>";
    }
    if ($x++ >=1) {
    break;
    }
    }
    ?>

    </div>[/code]
    I took the code in the html result page of a video.
    It should work fine.
    The player is displayed, but when i click to start the movie, it doesn't load it.
    Looking on the code, i found the problem.
    [code]$imageURL[/code] returns this path \video\videoname\video.flv but the correct path of the video is \video\albums\videoname\video.flv
    it losts \albums\.
    What can i do?
    thank you!!!
  • Antonio, replace
    `$imageURL = getURL($image);`
    with
    `$imageURL = getURL($image);

    $imageURL = str_replace("video",'video/albums',$imageURL);`
    this shoulkd add albums to the imageURL
  • Hi Bert, thank you so much for your support!!
    Now i can display and see the movie, but there's a think i'm not understanding.
    How does zp take the last video?
    If i change the date in zp admin, i don't display the last movie (but ordering by date in zp configuration displays them correctly in the zp index).
    So i tried to change date on the machine, and for every day i made and then i've inserted a movie. I tried this with 4 movies. All was ok to the third movie, when i inserted the fourth i'm continuing to display the third. I don't know why...
    thank you again!!
  • acrylian Administrator, Developer
    The latest stuff is fetched by ID, since that is the unique value that is automatically assigned when uploading anything. So it follows the upload order, not any dates.
  • antonio, what you can do is hack your template-functions.php and around line
    2597 in the getimagestatistic function change:

    `case "latest":

    $sortorder = "images.id"; break;`

    to

    `case "latest":

    $sortorder = "images.date"; break;`

    this works for my images...
  • Hi boys
    i'm testing it locally with xampp, by copiyng and pasting (not by ftp).
    before working on the date, i had the same problem.
    Is possible that the old id were assigned on the new (i didn't rename video folders)?
    Bert, hacking the template-funcions.php will modify the normal zenphoto working? I have it working by itslef in the site.
    Thanks and sorry for my english!!!
  • Antonio

    you can change this in the template functions;

    after the lines:
    `case "latest":

    $sortorder = "images.id"; break;

    `

    add:

    `case "date":

    $sortorder = "images.date"; break;`

    so the sort part in the getImageStatistic looks like:

    `switch ($option) {

    case "popular":

    $sortorder = "images.hitcounter"; break;

    case "latest":

    $sortorder = "images.id"; break;

    case "date":

    $sortorder = "images.date"; break;

    case "mostrated":

    $sortorder = "images.total_votes"; break;

    case "toprated":

    $sortorder = "(images.total_value/images.total_votes)"; break;

    }

    `

    then on the page where you want the latest video in the code from above use:

    `$images = getImageStatistic($_zp_gallery->getNumImages(), "date");`

    by this the function getImageStatistic($number, "latest"); stays intact wherever used on your site.
    note..if you upgrade your zenphoto the template-functions file will be overwritten and you'll have to add those lines again..
  • acryllian.. I believe dates are fetched from the exif or not?
    so if latest images get sorted by date they will show up chronolocillay by the date the picture was taken?

    Is it an idea to add this the template-functions getimageStatistic in the build?

    `case "byimagedate":

    $sortorder = "images.date"; break;`

    to get an getImageStatistic(50,"byimagedate") show the latest 50 pics in ordere the were shot

    or am i missing something?
  • acrylian Administrator, Developer
    Bert, that date option makes absolutly sense. Consider it done...:-)

    Just to explain why it is missing since I did that function: I do not take photos myself, I am mainly an illustrator and designer, therefore I tend to forget that people want to use the date a photo is taken and not the upload.
  • thanks acryllian , just saw it's in the build already

    Antonio Acryllian added the sort by 'image date' for the to the getImageStatistic() function by adding a case 'latest-date'to the nightly build so you don't have to mess with the templates function

    complete code is now

    `

    <?php<br />
    $images = getImageStatistic($_zp_gallery->getNumImages(), "latest-date");

    $x = 1;

    foreach ($images as $image) {

    if (is_null($image->getVideoThumb())){$x=$x-1;}else{

    $imageURL = getURL($image);

    $imageURL = str_replace("video",'video/albums',$imageURL);

    echo "imagegetThumb()."\">";

    }

    if ($x++ >=5) {

    break;

    }

    }?>`
  • Hi all, yesterday evening i tried to have working the new hacks. It is not working.
    Now i've seen the new zenphoto release, i downloaded it and upgraded zenphoto, i deleted the cache folder, and re-inserted 2 videos. Zenphoto is working, but when I call the page with this code
    <?php
    $images = getImageStatistic($_zp_gallery->getNumImages(), "latest-date");
    $x = 1;
    foreach ($images as $image) {
    if (is_null($image->getVideoThumb())){$x=$x-1;}else{
    $imageURL = getURL($image);
    $imageURL = str_replace("video",'video/albums',$imageURL);
    echo "<img src=\"".$image->getThumb()."\">";
    }
    if ($x++ >=5) {
    break;
    }
    }?>
    i get an error:
    Zenphoto Error
    MySQL Query ( SELECT images.albumid, images.filename AS filename, images.title AS title, albums.folder AS folder, images.show, albums.show, albums.password FROM `zp_images` AS images, `zp_albums` AS albums WHERE images.albumid = albums.id AND images.show=1 AND albums.show=1 AND albums.folder != '' ORDER BY DESC LIMIT 2 ) Failed. Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC LIMIT 2' at line 1
    Is mysql version i'm running that generates it?
    I think is better if i try on the server, not in local, don't you?
  • acrylian Administrator, Developer
    Weird, we didn't change anything on that query...
  • this code is now working at the bottom of
    http://www.bertsimons.nl/zenphoto/contact/comments.jpg.php

    5 latest videos ordered by image-date

    `<?php <br />
    $images = getImageStatistic($_zp_gallery->getNumImages(), "latest-date");

    $x = 1;

    foreach ($images as $image) {

    if (is_null($image->getVideoThumb())){$x=$x-1;}else{

    $imageURL = getURL($image);

    $imageURL = str_replace("zenphoto",'zenphoto/albums',$imageURL);

    echo "
    ";

    echo "";

    echo "var so = new SWFObject("/zenphoto/zp-core/flvplayer.swf","player","320","240","7");";

    echo "so.addParam("allowfullscreen","true");";

    echo "so.addVariable("file","".$imageURL ."");";

    echo "so.addVariable("displayheight","310");";

    echo "so.write("player");";

    echo "";

    echo "
    ";

    }

    if ($x++ >=5) {

    break;

    }

    }?>`

    note replace the path's by yours
  • acrylian Administrator, Developer
    Maybe we should consider making that a template-function. I will see what the others think.
  • and you can insert

    `$preview = substr($imageURL,0,strrpos($imageURL,".")).".jpg";

    echo "so.addVariable(\"image\",\"".$preview ."\");";`

    to show the preview image of the video.
  • sorry for my wrong contain.
    now i made hacks in template functions.
    with the old code i'm continuing to dipslay only a video that doesn't change when i add others
    <p id="player">
    <?php
    $images = getImageStatistic($_zp_gallery->getNumImages(), "date");$x = 1;
    $x = 1;
    foreach ($images as $image) {
    if (is_null($image->getVideoThumb())){$x=$x-1;}else{
    $imageURL = getURL($image);
    $imageURL = str_replace("video",'/video/albums',$imageURL);
    echo "<script type=\"text/javascript\">";
    echo "var so = new SWFObject(\"/video/zp-core/flvplayer.swf\",\"player\",\"320\",\"240\",\"7\");";
    echo "so.addParam(\"allowfullscreen\",\"true\");";
    echo "so.addVariable(\"file\",\"".$imageURL ."\");";
    echo "so.addVariable(\"displayheight\",\"310\");";
    echo "so.write(\"player\");";
    echo "</script>";
    }
    if ($x++ >=1) {
    break;
    }
    }
    ?>
    With the new
    <?php
    $images = getImageStatistic($_zp_gallery->getNumImages(), "latest-date");
    $x = 1;
    foreach ($images as $image) {
    if (is_null($image->getVideoThumb())){$x=$x-1;}else{
    $imageURL = getURL($image);
    $imageURL = str_replace("video",'video/albums',$imageURL);
    echo "<div id=\"player\">";
    echo "<script type=\"text/javascript\">";
    echo "var so = new SWFObject(\"/video/zp-core/flvplayer.swf\",\"player\",\"320\",\"240\",\"7\");";
    echo "so.addParam(\"allowfullscreen\",\"true\");";
    echo "so.addVariable(\"file\",\"\".$imageURL .\"\");";
    echo "so.addVariable(\"displayheight\",\"310\");";
    echo "so.write(\"player\");";
    echo "</script>";
    echo "</div>";
    }
    if ($x++ >=2) {
    break;
    }
    }?>
    i get this error
    MySQL Query ( SELECT images.albumid, images.filename AS filename, images.title AS title, albums.folder AS folder, images.show, albums.show, albums.password FROM `zp_images` AS images, `zp_albums` AS albums WHERE images.albumid = albums.id AND images.show=1 AND albums.show=1 AND albums.folder != '' ORDER BY DESC LIMIT 4 ) Failed. Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC LIMIT 4' at line 1
    Bert, i saw your page and now know it's working.
    I think it is the mysql server version (..error in your SQL syntax...your MySQL server version for the right...).
    I will try on the server and inform you as soon as possible.
    Thanks a lot for yours gold help!!!!
  • don't make hacks in the template- functions file!, with last night nightly build it is not neccesary
  • Hi Bert, i haven't touched any file of zp. In a page outside zp folder there is this code:

    <?php
    define('ZENFOLDER', 'zp-core');
    define('WEBPATH', 'zenphoto');
    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");
    ?>
    <?php
    $images = getImageStatistic($_zp_gallery->getNumImages(), "latest-date");
    $x = 1;
    foreach ($images as $image) {
    if (is_null($image->getVideoThumb())){$x=$x-1;}else{
    $imageURL = getURL($image);
    $imageURL = str_replace ("zenphoto","zenphoto/albums",$imageURL);
    echo "<div id=\"player\">";
    echo "<script type=\"text/javascript\">";
    echo "var so = new SWFObject(\"/zenphoto/zp-core/flvplayer.swf\",\"player\",\"320\",\"240\",\"7\");";
    echo "so.addParam(\"allowfullscreen\",\"true\");";
    echo "so.addVariable(\"file\",\"\".$imageURL .\"\");";
    echo "so.addVariable(\"displayheight\",\"310\");";
    echo "so.write(\"player\");";
    echo "</script>";
    echo "</div>";
    }
    if ($x++ >=5) {
    break;
    }
    }?>

    I'm always returning the error. I tried on the server. I think i'm losing something...

    Zenphoto Error
    MySQL Query ( SELECT images.albumid, images.filename AS filename, images.title AS title, albums.folder AS folder FROM `zp_images` AS images, `zp_albums` AS albums WHERE images.albumid = albums.id AND images.show = 1 AND albums.folder != '' ORDER BY DESC LIMIT 26 ) Failed. Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC LIMIT 26' at line 1
  • what are the paths of your folders? did you now install in /zenphoto ? and are the videos inside an album in zenphoto/albums?
  • antonio, i maneged to get it working outside the zenphoto directory as you can see at

    http://www.bertsimons.nl/testlatestvideo.php

    `<?php<br />
    define('ZENFOLDER', 'zp-core');

    define('WEBPATH', 'zenphoto');

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    ?>







    <?php <br />
    $images = getImageStatistic($_zp_gallery->getNumImages(), "latest-date");

    $x = 1;

    foreach ($images as $image) {

    if (is_null($image->getVideoThumb())){$x=$x-1;}else{

    $imageURL = getURL($image);

    $imageURL = str_replace("zenphoto",'zenphoto/albums',$imageURL);

    echo "
    ";

    echo "";

    echo "var so = new SWFObject(\"/zenphoto/zp-core/flvplayer.swf\",\"player\",\"320\",\"240\",\"7\");";

    echo "so.addParam(\"allowfullscreen\",\"true\");";

    echo "so.addVariable(\"file\",\"".$imageURL ."\");";

    $preview = substr($imageURL,0,strrpos($imageURL,".")).".jpg";

    echo "so.addVariable(\"image\",\"".$preview ."\");";

    echo "so.addVariable(\"displayheight\",\"310\");";

    echo "so.write(\"player\");";

    echo "";

    echo "


    ";

    }

    if ($x++ >=5) {

    break;

    }

    }?>`

    i don't get an mysql error..
    but however to get the videos to show up I needed to at this at the top:

    `



    `

    this is normally called by zenphoto if inside zenphoto
  • Hi Bert, thank you again.
    Yesterday i forgot to paste <script type="text/javascript" src="/zenphoto/zp-core/js/flvplayer.js"></script>, but it is in the page.
    I made another folder called zenphoto with 5 video.
    Nothing to do, i'm always getting the error.
    Zenphoto works fine, i can see correctly all pages.
    I changed if ($x++ >=5) to if ($x++ >=1) to display only 1 or 2 video but the error persists.
    Now i try to clean the database and reinstalling zenphoto.
    I will inform you.
    Thank you Bert and thanks Acrylian.
Sign In or Register to comment.