1 of 4
1
gallery relationship
Posted: 14 August 2006 08:50 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  228
Joined  01-20-2006

hi all,

I’m looking for a way to relate my entries to a certain category in my gallery. enabling the relationship only allows me to pick a single picture from all (1000+) entries while I need at least 20 of them, all from the same category. using 20 or more custom fields is not an option so I’m looking for some other solution.

I was thinking of adding a custom field that holds the gallery id so it can be used in the gallery’s category parameter but that doesn’t seem to work. perhaps there is another way to do this I am unaware of?

 Signature 

buro taggetig: web design & event photography from Belgium.

(call me bob!)

Profile
 
 
Posted: 14 August 2006 08:53 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23751
Joined  05-20-2002

I’m pretty sure you should be able to use a custom field to hold the gallery id and then nest the gallery tag inside the weblog tag- though you would only want to do this on single entry pages (otherwise you’d be pinging the server pretty hard).

When you tried it- how’d you code the template?  Like I say- I’m fairly certain this will work.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 14 August 2006 10:07 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  228
Joined  01-20-2006

you are right. I don’t know what I did wrong but it’s working now. not the greatest first post as a paying customer but at least I’m learning.

 Signature 

buro taggetig: web design & event photography from Belgium.

(call me bob!)

Profile
 
 
Posted: 14 August 2006 10:10 AM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23751
Joined  05-20-2002

Hee- no, I love this kind of post.  It’s EASY!  Heh- glad you got it squared away. 

And if you need me to dig it up, I think I wrote an extension that creates a dropdown menu in the publish page- options are the gallery categories- select one and the gallery id is entered into the field.  Saves having to flip over to the gallery and look it up.  Give a yell if you want me to find it.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 14 August 2006 01:08 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  228
Joined  01-20-2006

that extension sounds great. I was already a bit worried that this method would be a hassle for some of my contributors.

rob1 - 14 August 2006 08:53 AM

though you would only want to do this on single entry pages (otherwise you’d be pinging the server pretty hard).

could you explain this to me briefly? I’m not quite sure what you mean here.

 Signature 

buro taggetig: web design & event photography from Belgium.

(call me bob!)

Profile
 
 
Posted: 15 August 2006 09:53 AM   [ Ignore ]   [ # 5 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23751
Joined  05-20-2002

Ah- the single entry page thing.  Keep in mind, when you use the weblog tag, it’s ‘looping through’ results.  So say you have the weblog tag displaying the last five entries.  IF you nested the gallery tag inside, it will be part of the loop- and basically you end up with the equivilant of using the gallery tag 5 times.  That’s a pretty good hit to the database.

So- if you are using the weblog tag to show a single entry- for example, a permalink or comment page- then having the gallery tag inside the weblog tag is no big deal.  You are only ‘running it’ once.  But if you’ve got it nested inside a tag that’s returning say 20 entries- that’s a lot of added queries and likely to slow things down. 

It’s always good to keep aware of how the weblog tag works when you start nested queries inside it.

And I dug up the extension- it was a real ‘quickie’- no settings interface and it was designed to pull categories from a single gallery.  Could be expanded if needed, so give a yell if that’s necessary.  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.  Should work.  Like I say- was a quicky.  But it should do the trick unless you have multiple galleries you need to draw from.  Easy enough to modify it if that were the case.

File Attachments
ext.gallery_cats.zip  (File Size: 2KB - Downloads: 472)
 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 21 September 2006 09:35 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
RankRankRank
Total Posts:  549
Joined  01-05-2005

Robin, this is exactly the thing I was just searching for.  cheers smile

 Signature 

Celebrating again soon.

Profile
 
 
Posted: 21 September 2006 09:46 AM   [ Ignore ]   [ # 7 ]  
Research Assistant
RankRankRank
Total Posts:  549
Joined  01-05-2005

Actually might have spoken too soon, have you managed to nest the gallery tag inside the weblog tag Robin?  Doesn’t seem to work for me.  Maybe I misunderstood what you were doing with the extension.

I’d only be nesting on a weblog single entry page btw.

 Signature 

Celebrating again soon.

Profile
 
 
Posted: 21 September 2006 09:52 AM   [ Ignore ]   [ # 8 ]  
Research Assistant
RankRankRank
Total Posts:  549
Joined  01-05-2005

ah feck.  it’s now working.  ignore me wink

 Signature 

Celebrating again soon.

Profile
 
 
Posted: 09 October 2006 07:44 PM   [ Ignore ]   [ # 9 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  769
Joined  03-22-2004

That is a great extension! Thanks! So many uses for it.

Profile
 
 
Posted: 23 February 2007 10:22 AM   [ Ignore ]   [ # 10 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1839
Joined  03-26-2006

WOW am I glad I just found this - hope it works like I think it will…

Thanks, Robin!

 Signature 

ryan masuga
—————
Masuga Design | Member, EE Pro Network
My EE Add-Ons | {devot:ee}
Twitter: masuga | masugadesign | devot_ee

Profile
 
 
Posted: 23 February 2007 10:47 AM   [ Ignore ]   [ # 11 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1839
Joined  03-26-2006

Yeah, of course, I’m having issues! I’m assuming the field_id I need is in the weblog_data table (in my case, I think it is 40…). And I know my gallery id is #1. Am I looking at the wrong field id?

I already had two entries that had a gallery relationship field (that showed single image entries…like how it’s supposed to work, I guess) and I was thinking this extension associated this dropdown to categories, rather than single images?

The other option I have is to make a custom field where they manually enter a number corresponding to the gallery category - but it would be nice if I could automate this a little bit.

WHAT THE…

Sure enough, after I write this post it seems to be working….

 Signature 

ryan masuga
—————
Masuga Design | Member, EE Pro Network
My EE Add-Ons | {devot:ee}
Twitter: masuga | masugadesign | devot_ee

Profile
 
 
Posted: 23 February 2007 02:24 PM   [ Ignore ]   [ # 12 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  6762
Joined  03-23-2006
mdesign - 23 February 2007 10:47 AM

Sure enough, after I write this post it seems to be working….

That’s always the way isn’t it?  Especially after Robin gives advice - things just seem to magically work wink

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
Posted: 24 February 2007 02:32 PM   [ Ignore ]   [ # 13 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1839
Joined  03-26-2006

When I output the gallery ona page, inside my weblog:entries tag, how to I properly display the the image titles, as the {title} variable belongs to the weblog:entries tag? I’m sure there’s a real easy exp:query we could write. Or someone could write for me. Ahem.

 Signature 

ryan masuga
—————
Masuga Design | Member, EE Pro Network
My EE Add-Ons | {devot:ee}
Twitter: masuga | masugadesign | devot_ee

Profile
 
 
Posted: 24 February 2007 02:37 PM   [ Ignore ]   [ # 14 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12779
Joined  04-29-2002

Ryan, how are you pulling in the gallery entry?

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 26 February 2007 11:09 AM   [ Ignore ]   [ # 15 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1839
Joined  03-26-2006

Well, I decided to use a short PHP query to get the gallery category so I could keep the gallery OUT of the weblog entries tag. However, the {title} field still just shows me the title of the Gallery category, rather than the title of the image, but it’s no big deal - wish I could figure that out, but it’s not a deal breaker. smile

You can see how I got the gallery working here: Sample Javascript Gallery. The caption is supposed to default to {caption} but if that is empty, it’s supposed to use the image title. However, the {title} tag is just returning the name of the gallery (clikc on various images and you’ll see many of them just say “2007 Bassmaster Classic” - which is just the gallery name).

 Signature 

ryan masuga
—————
Masuga Design | Member, EE Pro Network
My EE Add-Ons | {devot:ee}
Twitter: masuga | masugadesign | devot_ee

Profile
 
 
Posted: 26 February 2007 01:05 PM   [ Ignore ]   [ # 16 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23751
Joined  05-20-2002

You should be able to get the title via query- what’s your query look like?

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 12 March 2007 05:09 PM   [ Ignore ]   [ # 17 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1615
Joined  01-05-2007

Sorry to sound dumb but how do I get the Gallery ID Number? FOUND IT in the URL in the Status Bar smile Gallery ID is 2.


I have created my gallery with a category and uploaded some pics there. I can see the gallery and it’s all good.

Now I want to use this extension so I can create a new case study then assign a gallery category to it.

I have created a number of custom fields including one called ‘casestudy-gallery’ which I have defined as a Drop-down List. The ID for this is ‘8’ which I changed in the ext file. Unfortunately it doesn’t auto populate with category names :(

So to summarise -

1. I have changed the ext file to $alter_field = 8; and $results = $DB->query(“SELECT cat_id, gallery_id, cat_name FROM exp_gallery_categories WHERE gallery_id=2 ORDER BY cat_name”);

2. I created a Field Group with a custom field called ‘casestudy-gallery’ which I defined as a Drop-down List.

3. Doesn’t work :(


Any help is appreciated!!

 Signature 

 
Steven Hambleton | ExpressionEngine Development for Web & Graphic Design Agencies

Profile
 
 
Posted: 12 March 2007 06:01 PM   [ Ignore ]   [ # 18 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1615
Joined  01-05-2007

Scrap all that I am a bone head!!

I should have looked at the url in the status bar again!! It tells you the field id right at the end.

 Signature 

 
Steven Hambleton | ExpressionEngine Development for Web & Graphic Design Agencies

Profile
 
 
   
1 of 4
1
 
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: 66455 Total Logged-in Users: 70
Total Topics: 84828 Total Anonymous Users: 34
Total Replies: 455227 Total Guests: 252
Total Posts: 540055    
Members ( View Memberlist )
Newest Members:  jbcobbsOut_ThereChrisClowerstevelovePhoenix FirstgoyoqshimshimSchaapyglorie2557da2n