How to connect weblog entry to gallery category?
Posted: 30 May 2008 06:00 PM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  102
Joined  06-22-2007

I finally decided to use Relating Entries as a solution to my site’s articles. After successfully implementing the relationship, I found that you can connect only one gallery entry from the gallery in a weblog entry. May aim was to associate complete gallery category with some particular entry.

To make things more clear, here is one of my articles that consists a site of images from a specific gallery category.

So, is this possible with the Relating Entries, or should I continue do it manually?

Profile
 
 
Posted: 31 May 2008 04:10 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  19
Joined  11-05-2007

I’m not an expert in EE but a possible solution for this would be to create a custom field in your weblog and insert the appropriate gallery category id there, then inside the weblog:entries tag you would insert the gallery:entries tag and you would pass the value of the custom field to the category id, thus selecting all the photos you wish to display. The downside of this is that you won’t be able to insert text between your photos, but it could be a solution. Hope it helps.

{exp:weblog:entries entry_id="3" weblog="default_site" dynamic="off"}
{title}
{body}
{exp
:gallery:entries gallery="{gallery_name}" category_id="{phgall}"}
{
/exp:weblog:entries}

<table class="tableBorder" cellpadding="6" cellspacing="1" border="0" width="600px">

{entries}

{row_start}
<tr>{/row_start}

{row}
<td class="thumbs">

<
div class="title">{title}</div>
</
td>
{/row}

{row_blank}
<td class="thumbs">&nbsp;</td>{/row_blank}

{row_end}
</tr>{/row_end}

{
/entries}

</table>

{/exp:gallery:entries}
Profile
 
 
Posted: 31 May 2008 05:04 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  102
Joined  06-22-2007

Thanks Isabel, I thought about this solution a while ago, so maybe I’ll try to use it.

Profile
 
 
Posted: 31 May 2008 05:08 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  19
Joined  11-05-2007

smile You’re welcome. I hope you find a good solution!

Profile
 
 
Posted: 06 August 2008 02:06 PM   [ Ignore ]   [ # 4 ]  
Moderator
Avatar
RankRankRankRank
Total Posts:  2185
Joined  03-22-2004

Robin has done a lot of this work for you already by creating a little known about extension which basically creates a dropdown menu in the publish page- options are the gallery categories- select one and the category id is entered into the field.  Saves having to flip over to the gallery and look it up and adding gallery tags inside a weblog tag which will add to you queries.

Custom Field
Create a custom field with input text as type and give it a name like {gallerycategory}. On your field group page which lists your custom fields, hover your mouse over the field you created and look at the stats bar below which gives a long url and at the very end is your field_id. Make note of that.

Download the extension here. Be sure to change the 2 items mentioned

You’ll need to open up the extension- and on line 33 alter:
$alter_field = 32;

The number?  That should be the field id of the text field where you want the category id to be inserted.  That field will be ‘replaced’ on the user side by a dropdown filled with the category names.

On line 37 you’ll need to alter:
$results = $DB->query(“SELECT cat_id, gallery_id, cat_name FROM exp_gallery_categories WHERE gallery_id=2 ORDER BY cat_name”);

Change gallery_id=2 to equal the id number of whatever gallery you want to pull the categories from.

Change it, save it, upload it to the extensions folder- then enable the extension.

You can now use {gallerycategory} to grab your images from the specific category

 Signature 
Profile
MSG
 
 
Posted: 06 August 2008 10:40 PM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  17
Joined  07-22-2008

you rock!

thanks.

im having a hard time getting it to work for now, but ill ask in the other thread.


high five sir!

Profile
 
 
Posted: 23 March 2009 07:33 AM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  8
Joined  03-19-2009

While looking for a solution for a similar problem I found this thread.

I have a weblog “Projects” and I want to associate each project with a category from the “projects” gallery. I created a weblog field named “screenshots_category” which holds the id of the gallery category containing the screenshots I wish to associate with the weblog entry.

I use the following (simplified) code to display the weblog entry with it’s assigned gallery category:

{exp:weblog:entries weblog="projects" category="5" limit="3" dynamic="off"}
    {title}
    {description}

    {exp
:gallery:entries gallery="projects" category="{screenshots_category}" dynamic="off" orderby="date" sort="asc" columns="1" rows="999"}
        {entries}
            {row}
                {entry_id}
                {image_url}
                
<p class="navigation">
                    <
span>{count} / {total_results}</span>
                </
p>
            
{/row}
        {
/entries}
    {
/exp:gallery:entries}
{
/exp:weblog:entries}

It works to a certain degree. The image url is correct and the images are displayed but {entry_id} is equal to the weblog entry’s id, not to the image’s id. Also, {count} and {total_results} are always equal to 1, no matter how many images there are.

For testing purposes I set the gallery category id manually and deleted the {exp:weblog:entries} tag which produced the desired result, so the problem seems to be the nesting inside the weblog:entries tag.

Does anybody have a solution to this problem?
Thanks in advance

Profile
 
 
Posted: 23 March 2009 07:44 AM   [ Ignore ]   [ # 7 ]  
Summer Student
Total Posts:  17
Joined  07-22-2008

i believe you can take the dynamic parameters out.

Ive done something similar and i noticed i didnt have them in there.

Profile
 
 
Posted: 23 March 2009 07:47 AM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  8
Joined  03-19-2009

Took them out but nothing has changed. Thanks for the suggestion. smile

Any other ideas?

Profile
 
 
Posted: 23 March 2009 08:03 AM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  17
Joined  07-22-2008
{exp:weblog:entries weblog='{segment_1}' dynamic='on' disable='member_data|trackbacks' category='{segment_2}' orderby='date' sort='desc' limit='5' paginate_base="{segment_1}/{segment_2}/page" paginate="bottom"}{if no_results}{redirect='404'}{/if}

{title}

{body_members}

   {if member_galcat
!=""}
    
    
    {exp
:gallery:entries gallery="member_gallery" orderby="random" category="{member_galcat}"}
    
                  
<table border="0">
            
                    
{entries}
                    
                    {row_start}
<tr>{/row_start}
                    
                    {row}
                    
<td class="thumbs" align="center">
                    <
a href="{image_url}" class="thickbox" rel="sample{entry_id}"><img src="{thumb_url}" width="{thumb_width}" height="{thumb_height}" /></a>
                    
                    </
td>
                    
{/row}
                    
                    {row_blank}
<td class="thumbs">&nbsp;</td>{/row_blank}
                    
                    {row_end}
</tr>{/row_end}
                    
                    {
/entries}
                
                
</table>
           
            
{/exp:gallery:entries}
        {
/if}
{
/exp:weblog:entries}

You dont have to use the segment_1 and _2 parts. i use it because it works for the project that im working on.

Profile
 
 
Posted: 23 March 2009 08:11 AM   [ Ignore ]   [ # 10 ]  
Summer Student
Total Posts:  8
Joined  03-19-2009

Thanks for your code snippet but I guess it’s no solution to my problem. As far as I can see you even rely on the “error” with {entry_id} being equal to the weblog entry’s id and not the image id, which I need fixed.

To clarify my problem: I need {entry_id} to output the image’s id, not the weblog entry’s id and I need {count} and {total_results} to work.

Profile
 
 
Posted: 23 March 2009 08:14 AM   [ Ignore ]   [ # 11 ]  
Summer Student
Total Posts:  17
Joined  07-22-2008

OOOOOOH i see now. yea good luck with that.

im not sure if there is a way to do that. I know there is a problem with the count and related gallery entries. Im not sure what exactly it is though.

Profile
 
 
Posted: 23 March 2009 08:31 AM   [ Ignore ]   [ # 12 ]  
Summer Student
Total Posts:  8
Joined  03-19-2009

Ok, I’ve got the solution. I created a new template holding the gallery:entries tag which is embedded into the weblog:entries tag. Like so:

Template: projects/index

{exp:weblog:entries weblog="projects" category="5" limit="3" dynamic="off"}
    {title}
    {description}

    {embed
="_includes/.project_screenshots" category="{screenshots_category}"}
{
/exp:weblog:entries}

Template: _includes/.project_screenshots

{exp:gallery:entries gallery="projects" category="{embed:category}" orderby="date" sort="asc" columns="1" rows="999"}
    {entries}
        {row}
            {entry_id}
            {image_url}
            
<p class="navigation">
                <
span>{count} / {total_results}</span>
            </
p>
        
{/row}
    {
/entries}
{
/exp:gallery:entries}

Works great. I’m new to EE so I still have to wrap my head around the whole embed thing. Thanks for your replies. smile

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 77460 Total Logged-in Users: 32
Total Topics: 101503 Total Anonymous Users: 20
Total Replies: 544234 Total Guests: 276
Total Posts: 645737    
Members ( View Memberlist )