<div dir="ltr"><div dir="ltr"><div dir="ltr">Thanks for this, this is most useful. </div><div dir="ltr">Yes I meant the scenario where there are no 'incoming links' to the category page, so thanks very much for the code<br><div><br></div><div>For the scenarios:</div><div>1) a call a page Main/NoSuchPage: the page Site.PageNotFound displays</div><div>2) a call Category/NoSuchPage: a blank page displays (plus whatever is in the group header or group footer).</div><div><br></div><div>I suspect this may be in StdMarkup.php, line 391 viz</div><div><br></div><div><div># This is a temporary workaround for blank category pages.</div><div># It may be removed in a future release (Pm, 2006-01-24)</div><div>if (preg_match("/^$CategoryGroup\\./", $pagename)) {</div><div>  SDV($DefaultPageTextFmt, '');</div><div>  SDV($PageNotFoundHeaderFmt, 'HTTP/1.1 200 Ok');</div><div>}</div></div><div><br></div><div>I'll try your local configuration override, but take into account the variable $CategoryGroup</div><div><br></div><div>thanks again</div><div><br></div><div>Simon</div></div></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sun, 19 Jan 2025 at 23:16, Petko Yotov <<a href="mailto:5ko@5ko.fr">5ko@5ko.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 18/01/2025 21:45, Simon wrote:<br>
> Category pages are perhaps the only time where PmWiki renders pages<br>
> when they do not exist.<br>
<br>
PmWiki renders the Site.PageNotFound text if any requested page doesn't <br>
exist, with a header "HTTP/1.1 404 Not Found".<br>
<br>
For Category pages which does not exist, the Site.PageNotFound text is <br>
not shown, the header is "HTTP/1.1 200 Ok" and the Group Footer includes <br>
a pagelist with backlinks.<br>
<br>
This can be overridden in local configuration, for example:<br>
<br>
   # Show PageNotFound for category pages that don't exist<br>
   if (preg_match("/^Category\\./", $pagename)) {<br>
     $DefaultPageTextFmt = '(:include Site.PageNotFound:)';<br>
     $PageNotFoundHeaderFmt = 'HTTP/1.1 404 Not Found');<br>
   }<br>
<br>
> Is it possible to test, in code, if a category exists?<br>
> (I want to count in TotalCounter hits on Category pages for categories<br>
> that do exist only, as TotalCounter (no longer) counts (the very many)<br>
> hits to pages that do not exist).<br>
<br>
It depends on what does "category exists" means. If it is "Category page <br>
exists", you have the PageExist($pagename) function.<br>
<br>
Look up the documentation about $AutoCreate on how to automatically <br>
create category pages when saving a page linking to them.<br>
<br>
OTOH if "category exists" means "there are currently incoming links", <br>
you can check if a pagelist has any pages, then the category "exists".<br>
<br>
   # if you call your code before stdconfig.php<br>
   include_once("$FarmD/scripts/pagelist.php");<br>
<br>
   # define array and options<br>
   $list = [];<br>
   $opt = [ 'link' => $pagename ];<br>
   FPLTemplatePageList($pagename, $list, $opt);<br>
<br>
   # $list has now pages that link to $pagename.<br>
   if($list) {} # 1+ incoming links, category "exists"<br>
<br>
<br>
> Is it possible to have PmWiki not render a category page if the<br>
> category does not exist?<br>
<br>
To display the Site.PageNotFound text when there are no incoming links, <br>
you can place in the pagelist "template none" section:<br>
<br>
   (:include Site.PageNotFound:)<br>
<br>
I would probably create a pagelist template for the Category listings <br>
separate from the search templage.<br>
<br>
Petko<br>
</blockquote></div>