Has anyone created a custom Fieldtype (for Fieldframe… or not) that shows a drop-down menu listing the templates in a pre-defined template group? Or, one that shows ALL the template groups and templates in a couple of side-by-side selects, akin to the weblog & category select boxes in the default advanced search form?
I’ve not seen one that can do the latter but you could probably use the HD SQL Select FF FIeld Type to create a drop-down that would list templates in a certain group.
Don’t know if that helps at all maybe?
Best wishes,
Mark
Hmm… that might help, but SQL scares me. :p At the moment I’m trying to reverse-engineer the NG Member List extension, since I think that’s functionally the closest to what I want - it just fetches member groups and members instead of template groups and templates.
Ok, I’ve got it reverse-engineered to do what I need, but I’ve got one quibble. When I output the value of the field in a template, I want to see “template_group/template”. To do this, instead of storing the template_id, I’m using the actual template group and template names as the value of the select options: <option value=”stylesheets/default”>stylesheets/default</option>. This has the obvious disadvantage of not being able to rename the templates without loosing any associations made to them.
Referring to them by ID would be better, but when actually outputting the custom field’s value in a template, how would I get the extension to lookup that template’s group_name and template_name when being output in a template? Sounds confusing, I know. :p
From look at the docs, it seems that the “display_tag” function would do it, but I don’t even know where to start. I’ll keep looking, but if someone has the answer, I’d be very appreciative and thankful. :p
Ok, I just need help to sort this SQL out:
$sql = " SELECT group_name, template_name";
$sql .= " FROM ".$this->db_prefix."_template_groups, ".$this->db_prefix."_templates";
$sql .= " WHERE ".$this->db_prefix."_templates.template_id = ".$field_data;
$sql .= " AND ".$this->db_prefix."_templates.group_id = ".$this->db_prefix."_template_groups.group_id");I want it to get the “group_name” and “template_name” from the “template_groups” and “templates” tables, respectively, where the “template_id” equals the one specified in the weblog entry (“$field_data”), and the “template_groups.group_id” equals the “templates.group_id”
In short, I want to get the group_name and template_name from a specified “template_id” number.
EDIT: Nevermind; I see my typo (extraneous “)” at the end of the query). I’ll post the working extension once I’ve tested it some more.
Sorry haven’t looked at this fully but you could easily do this with the HD SQL extension with this sort of thing :
SELECT concat(tg.group_name, '/', wt.template_name)
FROM exp_template_groups tg
LEFT JOIN exp_templates wt
ON tg.group_id = wt.group_id
WHERE tg.group_id = '1'Just change the tg.group_id = ‘1’ to the number of the template group that you wish to bring back the templates for.
Hope that helps a bit.
Best wishes,
Mark
Thanks for the help, Mark, but I’d already figured it out! 😝
Thanks for the help, Mark, but I’d already figured it out! 😝 http://ellislab.com/forums/viewthread/144591/
Ah glad you got something sorted.
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.