2017-04-07, 17:02:50
2017-04-07, 18:20:21
To check page exist you can use global $pagesArray variable, it contains cached page data:
Another, quicker option would be to check it manually with native file_exist() PHP method, for example:
PS. Do not forget to sanitize the user input!
Code:
global $pagesArray;
if(isset($pagesArray[$slug])) echo 'Page exist';
else echo 'Page does not exist';
Another, quicker option would be to check it manually with native file_exist() PHP method, for example:
Code:
if(file_exists(GSDATAPAGESPATH.$slug.'.xml')) echo 'Page exist';
else echo 'Page does not exist';
PS. Do not forget to sanitize the user input!
2017-04-07, 18:56:47
(2017-04-07, 18:20:21)Bigin Wrote: [ -> ]To check page exist you can use global $pagesArray variable, it contains cached page data:
Code:global $pagesArray;
if(isset($pagesArray[$slug])) echo 'Page exist';
else echo 'Page does not exist';
Another, quicker option would be to check it manually with native file_exist() PHP method, for example:
Code:if(file_exists(GSDATAPAGESPATH.$slug.'.xml')) echo 'Page exist';
else echo 'Page does not exist';
PS. Do not forget to sanitize the user input!
Nice solution
I use this for my template functions.php
Thank you.