Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: r3822/3: New Sections panel
wet wrote:
I think that since we now display each section’s article_count it would deserve its own sortable table column. It would be much more useful without requiring a lot of additional code.
What about performance? The counting currently adds up to 100 extra individual queries to the page. Joining the queries wouldn’t be a bad idea. Which is probably what you, Robert, are thinking of, if you are making the column sortable.
Offline
Re: r3822/3: New Sections panel
I’m thinking of nothing particular at all but just trying to influence Stef as he’s this feature’s owner ;)
Offline
Offline
Re: r3822/3: New Sections panel
@gocom
I think you’re right about the create new section field on sections list page. It should instead be just a link to the edit form like on users page. In the future that edit panel will be modal so that’d work fine
Offline
Re: r3822/3: New Sections panel
Above sub-query in a form of a patch:
Index: include/txp_section.php
===================================================================
--- include/txp_section.php (revision 3828)
+++ include/txp_section.php (working copy)
@@ -160,10 +160,9 @@
list($page, $offset, $numPages) = pager($total, $limit, $page);
echo n.section_search_form($crit, $search_method).'</div>';
+
+ $rs = safe_rows_start('*, (SELECT count(*) FROM '.safe_pfx('textpattern').' articles WHERE articles.Section = txp_section.name) AS article_count', 'txp_section', "$criteria order by $sort_sql limit $offset, $limit");
- $rs = safe_rows_start('*', 'txp_section',
- "$criteria order by $sort_sql limit $offset, $limit");
-
if ($rs)
{
echo n.'<div id="'.$event.'_container" class="txp-container">';
@@ -194,8 +193,7 @@
a.'dir='.$dir.a.'page='.$page.a.'search_method='.$search_method.a.'crit='.$crit;
$page_url = '?event=page'.a.'name='.$sec_page;
$style_url = '?event=css'.a.'name='.$sec_css;
- $article_count = safe_count('textpattern', "Section = '".doSlash($sec_name)."'");
-// $can_delete = ($sec_name == 'default' || $article_count > 0) ? false : true;
+// $can_delete = ($sec_name == 'default' || $sec_article_count > 0) ? false : true;
$is_default_section = ($sec_name == 'default');
echo tr(
@@ -208,7 +206,7 @@
td(txpspecialchars($sec_title), '', 'name').
td(
'<a href="'.$page_url.'" title="'.gTxt('edit').'">'.$sec_page.'</a>'.n.
- ( ($article_count > 0) ? '<a title="'.gTxt('article_count', array('{num}' => $article_count)).'" href="?event=list'.a.'step=list'.a.'search=Go'.a.'search_method=section'.a.'crit='.htmlspecialchars($sec_name).'">('.$article_count.')</a>' : ($is_default_section ? '' : '(0)') )
+ ( ($sec_article_count > 0) ? '<a title="'.gTxt('article_count', array('{num}' => $sec_article_count)).'" href="?event=list'.a.'step=list'.a.'search=Go'.a.'search_method=section'.a.'crit='.htmlspecialchars($sec_name).'">('.$sec_article_count.')</a>' : ($is_default_section ? '' : '(0)') )
, '', 'page').
td('<a href="'.$style_url.'" title="'.gTxt('edit').'">'.$sec_css.'</a>', '', 'style').
Which then allows easily using article_count
in the order by statement, and creating sortable <table>
columns with it. Plus it saves memory and 100 queries.
Offline
Re: r3822/3: New Sections panel
philwareham wrote:
I think you’re right about the create new section field on sections list page. It should instead be just a link to the edit form like on users page. In the future that edit panel will be modal so that’d work fine
Speaking of links and Users panel; shouldn’t those be links too? Currently on the User’s panel those are forms too with buttons. I.e. shouldn’t this:
<form method="post" action="index.php" id="change_password"><p><input type="submit" value="Change your password" /><input type="hidden" value="admin" name="event" /><input type="hidden" value="new_pass_form" name="step" /></p>
<input type="hidden" value="11e2da4b41b1a2d7ad1a65104bfca654" name="_txp_token" />
</form>
<form method="post" action="index.php" id="author_create"><p><input type="submit" value="Add new author" /><input type="hidden" value="admin" name="event" /><input type="hidden" value="author_edit" name="step" /></p>
<input type="hidden" value="11e2da4b41b1a2d7ad1a65104bfca654" name="_txp_token" />
</form>
</div>
Be just simply:
<p class="nav-tertiary"><a class="navlink" href="?event=users&step=new_pass_form">Change your Password</a><a class="navlink" href="#">Add new author</a></p>
Last edited by Gocom (2012-06-23 06:53:00)
Offline
Re: r3822/3: New Sections panel
Gocom wrote:
Above sub-query in a form of a patch:
Nice. I won’t be working on this today so if Robert or someone else wants to take over for a bit then by all means go for it. I hadn’t thought about the Create button problem and agree it should work like the Add New Author button (or, if the Input box remains, jump straight to the Edit step like the Links panel does).
I don’t mind either way: single button-to-edit-step (probably best) or Button-plus-control that jumps to the Edit step. Whichever it is, we should probably standardise it on the links panel too.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: r3822/3: New Sections panel
Gocom wrote:
Speaking of links and Users panel; shouldn’t those be links too?
They were in an earlier version but (istr, might be wrong) Phil preferred buttons and didn’t want to hack a link in CSS to make it look like a button.
It doesn’t bother me at all. Spin the wheel and choose. Link… button… link… button. Whoever commits it to core, these are the places it affects:
- Admin List panel
- Section List panel
- Links list panel
- Comments list panel (show banned IPs)
I think that’s it, from memory.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: r3822/3: New Sections panel
@gocom
I would say yes, just plain nav tertiary links, but Stef did those buttons so maybe there’s a reason they had to be Individual forms? I’ll ask.
Offline
Re: r3822/3: New Sections panel
philwareham wrote:
I would say yes, just plain nav tertiary links, but Stef did those buttons so maybe there’s a reason they had to be Individual forms? I’ll ask.
Hehe, OK maybe it was me! I’ve lost the plot with all the back and forth in code. Just choose the best method and go for it.
EDIT: actually it might have been a holdover from when the Form had an input box as well and I just removed the box but left the rest in place.
Last edited by Bloke (2012-06-23 07:09:00)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: r3822/3: New Sections panel
@bloke
I’d rather they were links, not buttons, without forms. Cheers.
Offline
Re: r3822/3: New Sections panel
philwareham wrote:
I’d rather they were links, not buttons, without forms. Cheers.
Sweet. Apologies for the screwup.
Last edited by Bloke (2012-06-23 07:13:51)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline