Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthordime
    • CommentTimeMay 15th 2008
     
    I need some script for listing galleries alphabetically from collection. It is possible to do this by setting up order option in admin panel, but this will sort all galleries and I want to have separate pages for every letter (i.e. a.php, b.php. c.php etc). So, I would have some template where I will only need to change starting letter and script will then call from database from one collection and list alphabetically galleries with that starting letter and then arrange them so that I could have look like from picture below (every second row have different style).
    I currently make lists manually but now I have huge number of galleries with new added regularly so I need some automatism here.
    I think that for some experienced programmer this is not some big problem, but I'm ready to pay if it is needed.
    I hope I explained problem, if not, I'll describe in more detail.
    •  
      CommentAuthorsidtheduck
    • CommentTimeMay 15th 2008
     
    dime,

    I don't know if I understand completely.

    + I know that you want to have different files named a.php, b.php, c.php, etc. to pull in galleries starting with those letters only.
    - Did you want it to pull a list of 'albums' only or 'albums & collections'? Or is it when you navigate to a certain collection, you have a list of 26 letter links at the top to allow you to split the albums by initial letter?
    - Are these files separate from the regular gallery page or a part of it (i.e. is this a list on some other page on your site like a site map)?
    - Is this just a list of albums, or did you want thumbnails associated with each album/collection?

    That's all I can think of right now.
    • CommentAuthordime
    • CommentTimeMay 15th 2008
     
    I used wrong terminology. Whenever I said "gallery" I meant "album".

    I know that you want to have different files named a.php, b.php, c.php, etc. to pull in galleries starting with those letters only.


    Correct.

    Did you want it to pull a list of 'albums' only or 'albums & collections'? Or is it when you navigate to a certain collection, you have a list of 26 letter links at the top to allow you to split the albums by initial letter?


    I use only one collection where I have numerous albums, so I want to have 26 pages where on each page I will have list with links to albums with one initial letter. In my previous comment I forgot to insert screenshot of how this list should look, so here it is.



    Are these files separate from the regular gallery page or a part of it (i.e. is this a list on some other page on your site like a site map)?


    Yes, they are separated from regular Plogger installation (example, if we have Plogger installation in example.com/plogger, this files should be something like example.com/lists)

    Is this just a list of albums, or did you want thumbnails associated with each album/collection?


    Just list of albums, as in picture above.
    •  
      CommentAuthorsidtheduck
    • CommentTimeMay 15th 2008 edited
     
    The contents of 'a.php' (and others) could be as follows:
    <ul>
    <?php
    include_once("absolute_path_to_plogger/plog-globals.php");
    include_once("absolute_path_to_plogger/plog-load_config.php");
    include_once("absolute_path_to_plogger/plog-functions.php");

    global $config;

    //change this to the letter you want the album to start with
    $letter = "a";

    $query = "SELECT * from plogger_albums WHERE `name` LIKE '".$letter."%' ORDER BY `id` ASC";
    $result= mysql_query($query) or die
    ("Could not execute query : $query." . mysql_error());

    $i=0;
    while ($row=mysql_fetch_array($result)){
    $id = $row['id'];
    $name = $row['name'];
    $count = $i+1;
    $class = ($count%2) ? "color-1" : "color-2";

    echo "<li class=\"".$class."\"><a href=\"".$config['gallery_url']."?level=album&id=".$id."\">".$name."</a></li>\n";
    $i++;
    }
    if ($i==0){
    echo "<li class=\"color-1\">No '".$letter."' galleries found!</li>\n";
    }
    ?>
    </ul>


    *note: This is quick and dirty and does not check to see if there are any photos within that album. It just grabs any album name from the database.

    ETA: If you make up a quick sample page and either post or email me the code (including css, etc.), I can customize the above code to fit your sample.
    • CommentAuthordime
    • CommentTimeMay 16th 2008
     
    Thank you very much! You excellent understood what I meant and this your code is making what I wanted. I customized it with my previous code which made list as in above picture; instead of unordered list you used, I used table. Here is that code:

    echo "<tr>
    <td width=\"40%\" class=\"".$class."\"><a href=\"".$config['gallery_url']."?level=album&id=".$id."\" class=\"menu\">".$name."</a></td>
    </tr>\n";


    There are only two things that should be changed so that this code be perfect:
    1) this code doesn't makes alphabetical list of albums, but instead makes list of albums in order as they were created
    2) I use "craft-free" URLs and this script makes old style of URLs, so if it is possible to make them "craft-free"

    As I said in my first comment, I'm ready to reward for effort on this if there is need, either personally or to Plogger development (although this code could be used by anyone and could be used as example of Plogger customatization). Even without this, I planed that in next couple of days write comment about some my suggestions of Plogger future development and to report bugs on Trac which I already reported on this forum last summer, before I stopped participating in forum half a year ago (I saw that there are made some steps forward in development in recent months; btw which username is used on Trac, I couldn't access with this from forum, but see that people who reported bugs have some usernames?)

    Thanks again!
    •  
      CommentAuthorsidtheduck
    • CommentTimeMay 16th 2008
     
    Posted By: dimeThank you very much! You excellent understood what I meant and this your code is making what I wanted. I customized it with my previous code which made list as in above picture
    Great!

    Posted By: dime1) this code doesn't makes alphabetical list of albums, but instead makes list of albums in order as they were created
    Sorry about that. I should have checked my code better. Find:$query = "SELECT * from plogger_albums WHERE `name` LIKE '".$letter."%' ORDER BY `id` ASC";and replace with:$query = "SELECT * from plogger_albums WHERE `name` LIKE '".$letter."%' ORDER BY `name` ASC";

    Posted By: dime2) I use "craft-free" URLs and this script makes old style of URLs, so if it is possible to make them "craft-free"
    Find:.$config['gallery_url']."?level=album&id=".$id.and replace with:.generate_url("album",$id).

    Posted By: dimeAs I said in my first comment, I'm ready to reward for effort on this if there is need, either personally or to Plogger development
    That is up to you, but if you do wish to pay someone, make a donation to Plogger (instead of me).

    Posted By: dimeEven without this, I planed that in next couple of days write comment about some my suggestions of Plogger future development and to report bugs on Trac which I already reported on this forum last summer, before I stopped participating in forum half a year ago (I saw that there are made some steps forward in development in recent months;
    Sure thing. I can check your bug reports on the forums as well to see if they have already been taken care of

    Posted By: dimebtw which username is used on Trac, I couldn't access with this from forum, but see that people who reported bugs have some usernames?)
    Registered usernames are only given to the development team so bugs can be assigned to different members. You don't have to login to Trac to report bugs however. Just fill out your username or email in the text box indicated. If you wish to receive emails regarding that ticket, add your email to the CC: list.

    Also, before reporting any bugs, please search on the Trac to see if there have already been bugs reported that are now closed in the current development or to see if there is already a discussion going on regarding this issue. It really helps if things are in order and filed together. Thanks!
    • CommentAuthordime
    • CommentTimeMay 17th 2008
     
    Thanks for reply!

    First part of code (list's order) is working, but second change for URLs doesn't. It now creates URL in format:
    example.com/a.php?level=album&id=196
    where a.php is page where this code is inserted, so obviously those URLs are not correct.
    Maybe I didn't make good change, code is now:

    <a href=\"".generate_url("album",$id)."\" class=\"menu\">".$name."</a>


    About Trac: I'll certanly report that next week since I need some free time so that at once check all things I found and check if they were changed.
    •  
      CommentAuthorDeeJayOdie
    • CommentTimeMay 18th 2008
     
    I wonder if it is possible to have a similar script as pagination, but for letters. To sort albums into letters.
    •  
      CommentAuthorsidtheduck
    • CommentTimeMay 18th 2008
     
    Try this dime,

    Add to just below 'global $config;'
    global $config;
    define("PLOGGER_EMBEDDED","0");
    $config['base_url'] = $config['gallery_url'];


    I think that should work for you.

    Posted By: DeeJayOdieI wonder if it is possible to have a similar script as pagination, but for letters. To sort albums into letters.
    You could do pagination if you want. I'll see if I can find some time too and we can compare notes. :D
    • CommentAuthordime
    • CommentTimeMay 18th 2008
     
    Thanks again, sidtheduck, but created URLs are same. Maybe I insert code on wrong place, so here it is how it looks now:

    global $config;
    define("PLOGGER_EMBEDDED","0");
    $config['base_url'] = $config['gallery_url'];

    //change this to the letter you want the album to start with
    $letter = "a";


    (of course, this is part of code, everything else is same)
    •  
      CommentAuthorsidtheduck
    • CommentTimeMay 18th 2008 edited
     
    hmmmm . . . try the 0 without quotes and maybe move it up more:include_once("../plogger/plog-globals.php");
    define("PLOGGER_EMBEDDED",0);
    include_once("../plogger/plog-load_config.php");
    $config['embedded'] = 0;
    $config['use_mod_rewrite'] = 1;
    include_once("../plogger/plog-functions.php");

    global $config;
    $config['baseurl'] = $config['gallery_url'];

    //change this to the letter you want the album to start with
    $letter = "a";


    ETA: or you can try this (it seems to work on my server):include_once("../plogger/plog-globals.php");
    include_once("../plogger/plog-load_config.php");
    $config['embedded'] = 0;
    $config['use_mod_rewrite'] = 1;
    include_once("../plogger/plog-functions.php");

    global $config;
    $config['baseurl'] = $config['gallery_url'];

    //change this to the letter you want the album to start with
    $letter = "a";
    • CommentAuthordime
    • CommentTimeMay 20th 2008
     
    Your second code is working on my installation also. Thank you very much, I very appreciate your help.

    So, complete code should looks (update of first version of your code):

    <ul>
    <?php
    include_once("absolute_path_to_plogger/plog-globals.php");
    include_once("absolute_path_to_plogger/plog-load_config.php");
    $config['embedded'] = 0;
    $config['use_mod_rewrite'] = 1;
    include_once("absolute_path_to_plogger/plog-functions.php");

    global $config;
    $config['baseurl'] = $config['gallery_url'];

    //change this to the letter you want the album to start with
    $letter = "a";

    $query = "SELECT * from plogger_albums WHERE `name` LIKE '".$letter."%' ORDER BY `name` ASC";
    $result= mysql_query($query) or die
    ("Could not execute query : $query." . mysql_error());

    $i=0;
    while ($row=mysql_fetch_array($result)){
    $id = $row['id'];
    $name = $row['name'];
    $count = $i+1;
    $class = ($count%2) ? "color-1" : "color-2";

    echo "<li class=\"".$class."\"><a href=\"".generate_url("album",$id)."\">".$name."</a></li>\n";
    $i++;
    }
    if ($i==0){
    echo "<li class=\"color-1\">No '".$letter."' galleries found!</li>\n";
    }
    ?>
    </ul>