ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Slideshow Pro and Photo Gallery - show different gallery category on weblog entry by custom field?

August 28, 2009 12:14pm

Subscribe [4]
  • #1 / Aug 28, 2009 12:14pm

    charmedworks

    62 posts

    Hi, I have a working installation of Slideshow Pro integrated with my Photo Gallery module.

    The set up is so far very basic but working a-Ok.  I’ve set up the main slideshow (showing an entire Gallery) so that it can be embedded into any weblog entry.  Example here:
    [removed - this example is no longer available]

    The QUESTION - client would like the ability embed a slideshow based on gallery Category into various weblog entries. The slideshow would show ONLY images that are in a gallery Category, not the entire Gallery.  **I would like to do this using only one xml file (client can’t edit xml each time they want to add a new slideshow).

    Here is my current working xml file (based on the the fine 5pieces Slideshow Pro Tutorial, and my Gallery id is “2”)

    <?xml version="1.0" encoding="UTF-8"?>
    
    <gallery>
    
    {exp:query sql="SELECT cat_id,cat_folder FROM exp_gallery_categories WHERE gallery_id = '2'"} 
    
    {exp:gallery:entries gallery="gallery" category="{cat_id}" limit="500"}
    {exp:gallery:category_name}<album title="{category}" description="{category_description}" >{exp:gallery:category_name}
    
    {entries}
    <a href="http://www.buildinggoodness.org/testsite/images/gallery/{cat_folder}/{filename}.jpg">http://www.buildinggoodness.org/testsite/images/gallery/{cat_folder}/{filename}.jpg</a>
    {/entries}
    </album>
    {/exp:gallery:entries}
    
    {/exp:query}
    </gallery>

     

    I *thought* I might be able to do something like this:

    1. Set up a custom field which I called slideshow_id - client enters gallery Category number there.
    2. Change XML file to use that custom field for the category to pull slideshow images from.
    as follows:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <gallery>
    
    {exp:query sql="SELECT cat_folder FROM exp_gallery_categories WHERE gallery_id = '2' AND cat_id='{slideshow_id}'"} 
    
    {exp:gallery:entries gallery="gallery" category="{slideshow_id}" limit="500"}
    {exp:gallery:category_name}<album title="{category}" description="{category_description}" >{exp:gallery:category_name}
    
    {entries}
    <a href="http://www.buildinggoodness.org/testsite/images/gallery/{cat_folder}/{filename}.jpg">http://www.buildinggoodness.org/testsite/images/gallery/{cat_folder}/{filename}.jpg</a>
    {/entries}
    </album>
    {/exp:gallery:entries}
    
    {/exp:query}
    </gallery>

    But, that’s not working…

    I’m pretty new to Expression Engine and while I’m having fun learning I still need advice on how to get all bits & pieces to interact and hoping someone can share knowledge and advise on this interesting puzzle!

  • #2 / Aug 28, 2009 12:20pm

    charmedworks

    62 posts

    Oh, by the way this xml DOES work for pulling images for a gallery Category,(when I hard code the gallery Category number in to the SQL query AND the gallery Category number in exp:gallery:entries) -  that’s why I tried the custom field route.  However maybe the problem is trying to use the custom field in the SQL query?  Anyone know another way to get it there 😊

    <?xml version="1.0" encoding="UTF-8"?>
    
    <gallery>
    
    {exp:query sql="SELECT cat_folder FROM exp_gallery_categories WHERE gallery_id = '2' AND cat_id='2'"}
    
    {exp:gallery:entries gallery="gallery" category="2" limit="500"}
    {exp:gallery:category_name}<album title="{category}" description="{category_description}" >{exp:gallery:category_name}
    
    {entries}
    <a href="http://www.buildinggoodness.org/testsite/images/gallery/{cat_folder}/{filename}.jpg">http://www.buildinggoodness.org/testsite/images/gallery/{cat_folder}/{filename}.jpg</a>
    {/entries}
    </album>
    {/exp:gallery:entries}
    
    {/exp:query}
    </gallery>
  • #3 / Sep 03, 2009 11:02am

    charmedworks

    62 posts

    Anyone interested in helping with this?  It would sure be appreciated.

    Here is the latest (and I know, I’m working backward here from what works to what I can make work but I don’t know what else to do).

    I’m still trying to use a Custom Field {slideshow_id} that I added to entries which I would like to have a slideshow based on their Gallery folder category number.

    To that end, this works and I’ve left it running this way on the test URL above. (See where I hard coded in the Gallery folder category in this case number 2 into the XML file:)

    <?xml version="1.0" encoding="UTF-8"?>
    
    <gallery>
    
    {exp:query sql="SELECT cat_id,cat_folder FROM exp_gallery_categories WHERE gallery_id = '2'"} 
    
    {exp:gallery:entries gallery="gallery" category="2" limit="500"}
    {exp:gallery:category_name}<album title="{category}" description="{category_description}" >{exp:gallery:category_name}
    
    {entries}
    <a href="http://www.buildinggoodness.org/testsite/images/gallery/{cat_folder}/{filename}.jpg">http://www.buildinggoodness.org/testsite/images/gallery/{cat_folder}/{filename}.jpg</a>
    {/entries}
    </album>
    {/exp:gallery:entries}
    
    {/exp:query}
    </gallery>

    So then I replaced the hard coded number with the custom field I created, that custom field info is entered on entry where I want the slideshow to show (the only change, see where slideshow_id appears below:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <gallery>
    
    {exp:query sql="SELECT cat_id,cat_folder FROM exp_gallery_categories WHERE gallery_id = '2'"} 
    
    {exp:gallery:entries gallery="gallery" category="{slideshow_id}" limit="500"}
    {exp:gallery:category_name}<album title="{category}" description="{category_description}" >{exp:gallery:category_name}
    
    {entries}
    <a href="http://www.buildinggoodness.org/testsite/images/gallery/{cat_folder}/{filename}.jpg">http://www.buildinggoodness.org/testsite/images/gallery/{cat_folder}/{filename}.jpg</a>
    {/entries}
    </album>
    {/exp:gallery:entries}
    
    {/exp:query}
    </gallery>

    But, that doesn’t work - slideshow pro loads nothing, it loads but no images.

    What do I not understand about entries, custom fields, and moving the custom field data over to the xml file?  Clearly something, but what… I don’t know.

    Someone out there must be able to help, anyone?

  • #4 / Sep 04, 2009 3:43pm

    charmedworks

    62 posts

    Hi, please disregard the test link.  I still have the same questions about how to set up the code but am no longer running it on the test link as I can’t get the categories to work.

    Anyone from Expression Engine helping out in these forums?

  • #5 / Sep 04, 2009 6:10pm

    Beebs

    207 posts

    I emphathize you. I have similar conundrum and post in other thread and no help so far. I’ll keep my effort, and if I found solution, I let you know. Meanwhile, let’s wait any help.

  • #6 / Sep 09, 2009 11:40am

    John Henry Donovan

    12339 posts

    charmedworks,

    Did you check out part 2 of my tutorial?

    More info there on passing variables to the XML using SWFObject.

  • #7 / Sep 09, 2009 12:47pm

    charmedworks

    62 posts

    Yes I did take a look at that tutorial, however I am trying to do something slightly different which is include the slideshow on entry pages in different weblog(s) than the weblog I use for the gallery, so the parts of the tutorial relating to checking which category page is being used do not apply.

    I will add that I DID try to modify the part 2 tutorial instructions for use with my parameters but had no success with that, and feel that if there is some way to pass the custom field I have added to the entry where the slideshow will be embedded, to the main XML file, set up per the part 1 tutorial, that will be the easiest method - As my latest take on the problem is that we suspect the only issue with using the simpler method plus the custom field is one with Expression Engine’s order of processing information.

    We are working on a method to do surmount this via PHP at the moment and I can share solutions as we find them.

    Thank you so much for your tutorials as a starting point.

  • #8 / Sep 09, 2009 1:01pm

    John Henry Donovan

    12339 posts

    charmedworks,

    if there is some way to pass the custom field I have added to the entry where the slideshow will be embedded, to the main XML file, set up per the part 1 tutorial, that will be the easiest method -

    This is covered in the second tutorial. You will need to use SWFOject though and you can just pass the custom field through that.

    Robin has a field extension that allows you relate an entry to a gallery category which is what you will be passing.

  • #9 / Sep 09, 2009 1:31pm

    charmedworks

    62 posts

    hi, I just sent you a PM - thanks.

  • #10 / Sep 09, 2009 4:37pm

    charmedworks

    62 posts

    Hi,

    Based on the feedback I’ve re-tried using Part 2 to send my custom field info to the XML.

    I’m still having problems - perhaps based on this specific code you can let me know where this is going wrong.

    Here’s a link to take a look:
    [removed - this example is no longer available]

    Here is the code that I am using:

    images rss template in the gallery:

    {assign_variable:gallery_url="http://www.buildinggoodness.org/testsite/images/gallery/"}
    {assign_variable:gallery_name="gallery"}
    {assign_variable:gallery_number="2"}
    <?php global $IN; ?>
    <?xml version="1.0" encoding="utf-8"?>
    <gallery>
    {exp:query sql="SELECT cat_id,cat_folder FROM exp_gallery_categories WHERE gallery_id = '{gallery_number}' AND cat_id = '<?=$IN->GBL('album_id', 'GET');?>'"} 
    {exp:gallery:entries gallery="{gallery_name}" category="{cat_id}" limit="500"}
    <album title="{category}" description="{category_description}" id="{cat_id}">
    {entries}
    {gallery_url}{cat_folder}/{filename}.jpg
    {/entries}
    </album>
    {/exp:gallery:entries}
    {/exp:query}
    </gallery>

    php is enabled for this template and set to input

    php code in the template for the entry where the gallery appears (I replaced the {segemnt_3} from the tutorial with my custom field, {slideshow_id}:

    <?php
    $cat_id = '{slideshow_id}';
    $cat_id = substr($cat_id, 1);
    ?>

    embedded flash code in the template for the entry where the gallery appears:

    [removed]
    // <![CDATA[
    var fo = new SWFObject("http://www.buildinggoodness.org/testsite/images/gallery/slideshow.swf", "foo", "550", "400", "9", "#FFFFFF");
    fo.addVariable("xmlfile", "http://www.buildinggoodness.org/testsite/index.php/gallery/images/?album_id=<?php echo $cat_id;?>");
    fo.addParam("scale", "exactfit");
    fo.addParam("menu", "false");
    fo.write("flashcontent");
    // ]]>
    [removed]
    </div>

    php is enabled for this template and set to input

    Two problems that I see:

    1. The PHP call doesn’t look like it’s working to get the number from my custom field {slideshow_id}, because the output code in the file looks like this (see where it says album_id=slideshow_id):

    <div id="flashcontent" align="center">
    
    [removed]
    // <![CDATA[
    var fo = new SWFObject("http://www.buildinggoodness.org/testsite/images/gallery/slideshow.swf", "foo", "550", "400", "9", "#FFFFFF");
    fo.addVariable("xmlfile", "http://www.buildinggoodness.org/testsite/index.php/gallery/images/?album_id=slideshow_id}");
    fo.addParam("scale", "exactfit");
    fo.addParam("menu", "false");
    fo.write("flashcontent");
    // ]]>
    [removed]
    </div>

    2.To test if things would work without the custom field, I tried hard coding in the album_id in the code above, (so I changed it to album_id=2 which is one of my actual cat_id numbers) however I still got the messed up looking flash embed, so I think something is wrong with the way I set up with the flash file itself as well.

    I’m pretty sure the XML file is working properly because when I type in my own album id in the end of a URL I can get accurate looking result:
    [removed - this example is no longer available]

    I would appreciated someone with a more advanced eye looking this over! Thanks so much.

  • #11 / Sep 09, 2009 4:43pm

    charmedworks

    62 posts

    As far as what could be wrong with the flash file itself, there are two instructions in the tutorial that I do not fully understand.  Here they are with questions.

    1.

      * Add this to the first frame of the Actions Layer

    ssp.xmlFilePath=xmlfile;

    I am not sure *where* to add that, or if I added it in the right place. 

    2.

      Give it the instance name of ‘ssp‘

    I did this in the properties inspector - was that right?

  • #12 / Sep 09, 2009 6:04pm

    Beebs

    207 posts

    With regards to flash file itself, I think you do just fine. Look at here : http://upload.wikimedia.org/wikipedia/en/f/fa/ACTIONSCRIPT20.png

    1. The actions layer is the one at the top where you can see “Layer 1”

    2. The property panel is in the left hand corner just right on top of Start windows icon and Firefox icon. This is where you have to name the instance in the stage (the slideshow pro component) as “ssp”

    My sense is that the category called in within the segment 3 while entry_id (where slideshow_id reside)is not in segment 3. I could be wrong, I am still working on it

  • #13 / Sep 09, 2009 6:28pm

    charmedworks

    62 posts

    (I think?) I took reference to segment_3 out altogether.  That’s throwing me off - what is segment_3?

  • #14 / Sep 09, 2009 6:35pm

    Beebs

    207 posts

    (I think?) I took reference to segment_3 out altogether.  That’s throwing me off - what is segment_3?

    Since EE does not have physical page - I interpret segment is like folder where the file/entry reside. Sometimes you put file within folder - subfolder - sub subfolder - file.

    More about segment here : http://expressionengine.com/docs/templates/globals/url_segments.html

  • #15 / Sep 09, 2009 7:06pm

    charmedworks

    62 posts

    Thanks Beebs, that totally helps me understand segments.

    Yes - in my case I am trying to set up the Slideshow Pro without any reference to {segment_#} in the code as the weblog where my gallery is (/gallery/)and the weblog where I want the Slideshow Pro slideshows to generate (/projects/) are different.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases