include sitemap

General questions about CMSimple
Post Reply
stargazer96
Posts: 28
Joined: Sat Jul 07, 2012 6:16 pm
Location: Budapest, Hungary

include sitemap

Post by stargazer96 » Fri May 26, 2017 6:51 am

Hi everyone,

I have a custom 404 page which I load into content-page with geturl.
Would it be possible to have/include in the content-file or at the bottom of the -404.php- page the sitemap-page and not only a sitemap-link ?
(now I have
<h1>404</h1>
#CMSimple hide# #CMSimple $output.=geturl('http://mysite.com/404.php?&print').sitemaplink().searchbox();#
)
Thank you in advance for your answer and help.

cmb
Posts: 12891
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: include sitemap

Post by cmb » Fri May 26, 2017 9:55 am

Have a look at how the sitemap is build in cms.php:128ff (CMSimple 3.4):

Code: Select all

if ($f == 'sitemap') {
    $title = $tx['title'][$f];
    $ta = array();
    $o .= '<h1>'.$title.'</h1>';
    for($i = 0; $i < $cl; $i++)if(!hide($i))$ta[] = $i;
    $o .= li($ta, 'sitemaplevel');
} 
Basically, you'd have to construct $ta and pass it to li(). This might best be done in a user defined function:

Code: Select all

function showSitemap()
{
    global $cl, $h;
   
    $ta = array();
    for($i = 0; $i < $cl; $i++)if(!hide($i))$ta[] = $i;
    return li($ta, 'sitemaplevel');
} 
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

stargazer96
Posts: 28
Joined: Sat Jul 07, 2012 6:16 pm
Location: Budapest, Hungary

Re: include sitemap

Post by stargazer96 » Fri May 26, 2017 11:56 am

THANK YOU, WORK PERFECTLY !
I copied your script/function (showSitemap) in the cms.php and I put in the content-file at the <h1>404</h1> the following ".showSitemap()", and is working excellent!
Thank you Christoph for the clear, understandable and quick answer and working solution!
p.s.
would it be possible to appear also the -sitemap- heading (<h1>Sitemap</h1>) above sitemap?
Thank you,
Alex

cmb
Posts: 12891
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: include sitemap

Post by cmb » Fri May 26, 2017 12:07 pm

stargazer96 wrote:would it be possible to appear also the -sitemap- heading (<h1>Sitemap</h1>) above sitemap?
Yes. Just use the following function:

Code: Select all

function showSitemap()
{
    global $cl, $h, $tx;
   
    $ta = array();
    for($i = 0; $i < $cl; $i++)if(!hide($i))$ta[] = $i;
    return '<h1>' . $tx['title']['sitemap'] . '</h1>' . li($ta, 'sitemaplevel');
}
Consider to use a <h2> heading instead, since the "404" is already <h1>.
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

stargazer96
Posts: 28
Joined: Sat Jul 07, 2012 6:16 pm
Location: Budapest, Hungary

Re: include sitemap

Post by stargazer96 » Fri May 26, 2017 12:53 pm

EXCELLENT! Just working PERFECTLY !
(I used <h2> as you recommend it).
Thank you very much, I wish you a nice weekend!

Post Reply