Hi, I’m trying to do something which may not be possible in EE - I hope it is, but I’m not having much joy.
Ideally, I want to set up all the categories in the photo album, populate them with data, and then simply choose that gallery category from the publish form.
Is this the sort of thing I can do with the new related entries in the custom fields? I’m tying myself in knots trying to get this done :(
Thanks
To do this right, I believe your best bet is to write an extension- which I really don’t think would be that difficult in this case.
The related field type relates by entry- be it a gallery entry or a weblog entry. I believe you could finagle it to only show the link to the category - just using the {category_path=gallery/category} variable- but it’s not really optimum as the select box on the publish page lists pictures rather than categories. I personally wouldn’t go that way.
Populating a dropdown field via another field would be great- but gallery categories aren’t an option for that- so it’s a no go.
Thus- an extension. You could use the publish_form_field_text_input hook to go in and do a custom version of populating a dropdown field from the gallery categories. It would be the tact I would take. For an out of the box solution- look to the ‘related entries’ approach, which has some limitations in this particular case.
Hi, I’m trying to do something which may not be possible in EE - I hope it is, but I’m not having much joy. 1. I have a photo gallery set up using the module with categories for each photo ‘album’ 2. On a weblog entry, I want a link to go to a gallery category, not a specific entry, BUT I want to specify this in the publish form not within the post content.
If I understand you properly, this is doable. In fact, it’s similar to what I’m doing on a clients site, right now. I basically, set up an event gallery
Yes. Which isn’t a problem in their situation, but could be in yours. Since, I force the client to make the event category name the same name as the event itself, that could be used as a relationship. But I set this up before the relational features were added, and haven’t attempted to change it yet.
Yeah, my solution was/is pretty much procedural. When I teach the client how to batch process images. I go over the fact that category names, much match the event name, and that they need to capture the category_id after they add a new category. Typically, they process the photos before adding the event write-up, which means, that the category_id for the photos is readily available.
The extensions are pretty easy to pick up, and handy for this sort of thing. I just cobbled a quick one together- here. Basically, open it up- and because I was lazy and didn’t want to deal with settings- set a variable in the file:
$alter_field = 32;
That 32? It should be the number of a custom field you want populated by the gallery categories- a text field at the outset. We overwrite/populate it via the extension. One other thing you’ll want to tweak is the query:
$results = $DB->query(“SELECT cat_id, gallery_id, cat_name FROM exp_gallery_categories WHERE gallery_id=2 ORDER BY cat_name”);
Right now, it pulls all the categories from gallery_id 2- that could change however you need, including getting fancy and letting them pull from multiple galleries and format subcats whatever.
And that’s it. Stick it in the extensions folder, enable it- and wherever on your publish/edit form the custom field you specified in $alter_field shows up, it will be a dropdown populated by the gallery cats. They’ll see the names of the categories in the dropdown- though because I’m lazy- the values are simply the category ids rather than the url, but that could be easily changed.
Anyway- briefly tested and could be tweaked a lot. But the extensions are worth playing with- very handy stuff.
Rob, I think I got this working, and with the code added to the page with the custom field id it works for anything really.. I am assuming it is suposed to leave the chosen category ID in place of the tag…which it does. This saves people from having to know the cat id to bring in a gallery category Thanks!
I think it has been fixed now since I have been able to download the ext.
However, did not manage to get it working yet. May be some silly code. Added a custom field with a specific field number. Included that field number in the $alter_field but my entry form still shows a blank text line (indeed, text input selected). Gallery_id does exist etc etc. I am afraid I am making a very very stupid mistake. Anyway, if somebody has experienced this as well and found a solution, please let me know.
Many thanks and… EE rocks! Cheers, Lomax
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.