Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-01-18 04:29:44
- nardo
- Member

- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Request: mod zem_popup_cat to use category titles
I’m using zem_popup_cat (context-sensitive popup category list for Textpattern) on a project because it only displays categories with active articles
works great, but it only displays category names, not titles
anyone fancy taking a geek at the code and seeing if it’s easy enough to hack that in? or suggest other category plugins that generate a popup?
Offline
Re: Request: mod zem_popup_cat to use category titles
Very easy – I just modified my zem_popup_cat this morning.
You simply need to add the [title] field to the SQL SELECT statement, then output it in the dropdown instead of the [name]. I also modified to sort by [title] instead of [name], just to maintain alphabetical appearance. As such:
original SQL (beginning from line 13):
$rs = getRows(“SELECT DISTINCT c.name FROM “.PFX.“txp_category c, “.PFX.“textpattern t WHERE (t.Category1=c.name OR t.Category2=c.name) AND t.Status=4 $section_q ORDER BY c.name ASC”);
modified SQL:
$rs = getRows(“SELECT DISTINCT c.name, c.title FROM “.PFX.“txp_category c, “.PFX.“textpattern t WHERE (t.Category1=c.name OR t.Category2=c.name) AND t.Status=4 $section_q ORDER BY c.title ASC”);
Then to output the title in the dropdown, replace [name] with [title] on line 23 as seen here:
original PHP (beginning from line 17)
$out = “<select name=\“c\” onchange=\“submit(this.form)\”>”.n. t.”<option value=\”\”>”.htmlspecialchars($default).”</option>”.n; if ($rs) { foreach ($rs as $c) { $sel = ($pretext[“c”]==$c[“name”] ? “ selected=\“selected\”“ : “”); $out .= t.t.”<option value=\”“.urlencode($c[“name”]).”\”$sel>”. htmlspecialchars($c[“name”]).”</option>”.n; } $out .= “</select>”;
modified PHP:
$out = “<select name=\“c\” onchange=\“submit(this.form)\”>”.n. t.”<option value=\”\”>”.htmlspecialchars($default).”</option>”.n; if ($rs) { foreach ($rs as $c) { $sel = ($pretext[“c”]==$c[“name”] ? “ selected=\“selected\”“ : “”); $out .= t.t.”<option value=\”“.urlencode($c[“name”]).”\”$sel>”. htmlspecialchars($c[“title”]).”</option>”.n; } $out .= “</select>”;
Last edited by simmerdesign (2006-11-22 18:07:12)
Offline