Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-06-07 20:20:18

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Pagetop message duplicates code returned from server

I’m currently ironing out faults in my code for stm_article_order. I saw that there are portions duplicated in the source code, incl. duplicate ID, and that causes the new Hive 4.6 click menus to stay closed.

Now, that happens when I’ve saved the article order, not on first opening of the page. I could tie the strange behaviour down to my replacing the old style “Article order saved” header bar
$tmp .= "<span class='update'>Article order saved</span>";
with what I thought would do the job in the current Textpattern way:
pagetop(gTxt("stm_ao_article_order"),gTxt("stm_ao_article_order_saved"));

And exactly that latter line creates the duplications.

What am I doing wrong in my code? See also line 12, marked with bullets.

function stm_article_order(){
	global $img_dir;
	$tmp = "<div id='wrapper'><h1>".gTxt('stm_ao_article_order')."</h1> <!-- <p class='hint'>".gTxt('stm_ao_hints_for_using')." --> <!-- <br /><span>".gTxt('stm_ao_optional_warnings')."</span></p> --> ";

	if($navigation = gps("navigation")){
		parse_str($navigation);
		foreach($navigation as $section => $children){
			foreach($children as $position => $ID){
				safe_update("textpattern", "position = $position, Section = '$section'", "ID = $ID");
			}
		}
		pagetop(gTxt("stm_ao_article_order"),gTxt("stm_ao_article_order_saved")); // ••••••••••••••
	}
	pagetop(gTxt("stm_ao_article_order"));
	stm_article_order_css();

	$tmp .= sprintf("<form action='%s' method='post' class='stm_save'>

[etc., more form code]

Edit: Of course I also tried adding the line in question to $tmp but to no avail.

Last edited by uli (2016-06-07 21:05:03)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#2 2016-06-09 03:37:41

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: Pagetop message duplicates code returned from server

I think it should be (in my installation this works):

function stm_article_order(){
	global $img_dir;
	$tmp = "<div id='wrapper'><h1>".gTxt('stm_ao_article_order')."</h1> <!-- <p class='hint'>".gTxt('stm_ao_hints_for_using')." --> <!-- <br /><span>".gTxt('stm_ao_optional_warnings')."</span></p> --> ";

	if($navigation = gps("navigation")){
		parse_str($navigation);
		foreach($navigation as $section => $children){
			foreach($children as $position => $ID){
				safe_update("textpattern", "position = $position, Section = '$section'", "ID = $ID");
			}
		}
	}
	pagetop(gTxt("stm_ao_article_order"),gTxt("stm_ao_article_order_saved")); // Page title after saving article order
	stm_article_order_css();

	$tmp .= sprintf("<form action='%s' method='post' class='stm_save'>

[etc., more form code]

Offline

#3 2016-06-09 12:33:58

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: Pagetop message duplicates code returned from server

Thanks, GugUser, for chiming in.

You’re right, that would keep the menu clickable, I’ve tried that, too. But we’ve moved the messagepane out of the condition check so the page would open with the “Article order saved” message right from the start. That’s what I find so surprising, why does the pagetop snippet lead to a proper result in the one place (though with the undesired side effect of producing a permanently visible message) but duplicates code when it’s placed in another line?

Any idea welcome.

Last edited by uli (2016-06-09 12:39:19)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2016-06-09 12:47:28

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: Pagetop message duplicates code returned from server

uli wrote #299644:

But we’ve moved the messagepane out of the condition check so the page would open with the “Article order saved” message right from the start.

Ah, I had not realized this new defect.

Offline

Board footer

Powered by FluxBB