get page (or file) name with PHP for conditional Javascript

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
nyukuri
User
Posts: 123

get page (or file) name with PHP for conditional Javascript

Post by nyukuri »

Hello,

I need to add to my footer.php some Javascript code, but not on every page, for example the code should not be on any page of "profileprive", which is a table view (so not on profilepriveadd.php, profilepriveedit.php etc.)

I tried the following:

<?php
if (!preg_match('/profileprive/', CurrentPageID()))
{
?>
<script> etc... </script>
<?php
}
?>

But it doesn't work. How can I add the javascript code to my footer under the condition that the file name meets some criterias?


nyukuri
User
Posts: 123

Post by nyukuri »

I was too quick with my question, just found the answer:

<?php
if (strpos(basename($_SERVER['PHP_SELF']), 'profileprive') === FALSE)
{
?>
<script> ... </script>
<?php
}
?>


Post Reply