Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-07-06 22:37:46

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

$pageout['grand_total'] - Am I using this right?

For quite awhile now, I’ve been happily using Wet’s PHP snippet for custom “no search results found” messages. This afternoon I tried to follow his recommendation and use $pageout['grand_total'] instead of $thispage['total'], and things didn’t work out like I expected.

Here’s the code I used:

<txp:article pgonly="y" limit="50" category="Current" searchsticky="1" />
<txp:php>
  // AM 7-6-07: replaced $thispage['total'] with $pageout['grand_total']
  global $pageout; global $q;
  $query = htmlentities($q);
  echo( ($pageout['grand_total']==0 ?
  "<p>Your search for <strong>$query</strong> didn’t return any results. Test count: ".$pageout['grand_total']."." :
  "<p>Your search for <strong>$query</strong> ".
  "produced the following ".$pageout['grand_total']." results:</p>") );
</txp:php>

<ol class="search-results">
  <txp:article form="search_results" limit="50" searchsticky="1" />
</ol>

I ended up getting the “no results” message even when there were results. What’s really weird is that the test count I added produced nothing in the rendered page. Is this because I used searchsticky="1" in the first <txp:article /> tag? It looks like line 651 of publish.php (v4.0.4) could be what’s stopping me in my tracks here.

Related question: Would $pageout['grand_total'] even be the right thing to use here? It looks (lines 654 & 664) like $pageout['total'] is the one that takes offset into account, which was the whole point of this. Am I missing/misinterpreting something?

Offline

#2 2007-07-09 00:03:57

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: $pageout['grand_total'] - Am I using this right?

Offline

#3 2007-07-09 05:14:14

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: $pageout['grand_total'] - Am I using this right?

Thanks, Mary. I viewed the source of that plugin, and it uses $thispage['total']. My understanding is that this is not the preferred way of doing things (see the link in my original post). Am I mistaken?

Offline

#4 2007-07-10 01:52:54

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: $pageout['grand_total'] - Am I using this right?

I haven’t looked at the contents of Rob’s plugin.

What result do you get for var_dump($GLOBALS['pageout']);?

Offline

#5 2007-07-12 17:46:20

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: $pageout['grand_total'] - Am I using this right?

tag_error <txp:php> ->  Notice: Undefined index:  pageout  on line 8

textpattern/publish/taghandlers.php:2681 eval()
textpattern/publish.php:958 php()
processTags()
textpattern/publish.php:917 preg_replace_callback()
textpattern/publish.php:453 parse()
index.php:37 textpattern()

NULL

Offline

#6 2007-08-24 22:27:48

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: $pageout['grand_total'] - Am I using this right?

Any additional information on this? I’d still like to know if what I’m attempting is possible.

Offline

Board footer

Powered by FluxBB