Textpattern Forum

You are not logged in. Register | Login | Help

#21 2012-06-23 03:47:03

Gocom
Developer
Registered: 2006-07-14
Posts: 4,394
Website

Re: r3822/3: New Sections panel

wet wrote:

Whether for better or worse, at least it saves a few bytes and exploits our new-flangled JS l10n API.

Awesome API I might add. Been already using it heavily since it landed the SVN. It’s pretty neat how it uses events in its advantage to load the strings.


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#22 2012-06-23 03:49:05

wet
Developer
From: Lenzing, Austria
Registered: 2005-06-06
Posts: 3,087
Website

Re: r3822/3: New Sections panel

Gocom wrote:

It’s pretty neat how it uses events in its advantage to load the strings.

As in “not at all”, you mean?

Offline

#23 2012-06-23 04:06:11

Gocom
Developer
Registered: 2006-07-14
Posts: 4,394
Website

Re: r3822/3: New Sections panel

wet wrote:

As in “not at all”, you mean?

Opposite. Pretty amazing in fact (second time’s the charm, eh). But honestly, while I did say pretty, I did mean that it’s genuinely neat.

Last edited by Gocom (2012-06-23 04:07:50)


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#24 2012-06-23 05:21:15

wet
Developer
From: Lenzing, Austria
Registered: 2005-06-06
Posts: 3,087
Website

Re: r3822/3: New Sections panel

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.

Offline

#25 2012-06-23 05:39:57

Gocom
Developer
Registered: 2006-07-14
Posts: 4,394
Website

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.


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#26 2012-06-23 05:43:11

wet
Developer
From: Lenzing, Austria
Registered: 2005-06-06
Posts: 3,087
Website

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

#27 2012-06-23 05:55:46

Gocom
Developer
Registered: 2006-07-14
Posts: 4,394
Website

Re: r3822/3: New Sections panel

Adding tiny correlated subquery to the select statement should be enough. I.e.

(SELECT count(*) FROM ".safe_pfx('textpattern')." articles WHERE articles.Section = name) AS article_count

Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#28 2012-06-23 06:12:22

philwareham
Core designer
From: Farnham, Surrey, UK
Registered: 2009-06-11
Posts: 1,522
Website

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

#29 2012-06-23 06:26:15

Gocom
Developer
Registered: 2006-07-14
Posts: 4,394
Website

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.


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#30 2012-06-23 06:51:44

Gocom
Developer
Registered: 2006-07-14
Posts: 4,394
Website

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&amp;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)


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

Board footer

Powered by FluxBB