hide a page based on field value

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

hide a page based on field value

Post by saleh »

hello

I need to hide a page on the rating if the value entered in the field Activated =0
and Page appears, if the value entered in the field Activated =1

Try this code but the page disappear with both values 0 and 1

function MenuItem_Adding(&$Item) {
//var_dump($Item);
// Return False if menu item not allowed
if (CurrentUserLevel() <> 3 && CurrentUserLevel() <> -1 && $Item->Url == "programslist.php") {
ew_AddFilter($filter, " Activated <> 0 ");
return FALSE;
} else {
return TRUE;
}
}

Try this code and disappeared all visitors:
Note that visitors : (userlevels =0 Default) and ( userlevels =-2 Anonymous)
function MenuItem_Adding(&$Item) {
//var_dump($Item);
// Return False if menu item not allowed
if (CurrentUserLevel() <> 3 && CurrentUserLevel() <> -1 && $Item->Url == "programslist.php") {
$a= "SELECT * FROM programs WHERE Activated = 0";
return FALSE;
} else {
return TRUE;
}
}


saleh
User
Posts: 470

Post by saleh »

hello

I tried to search for field value Activated = 0
Then displays whether the value in the field of equal Activated = 1
Code but it does not implement the required properly
I hope that I got the information

// Write your global startup script here
// document.write("page loaded");
<?php if ($a= "SELECT * FROM programs WHERE Activated = 0" && CurrentUserLevel() <> -1 && CurrentUserLevel() <> 3 ) { ?>
$("#mi_programs").hide();
<?php } ?>


mobhar
User
Posts: 11712

Post by mobhar »

Use "ew_ExecuteScalar" global function if you want to get that single value from Database.

Please read "Some Global Functions" sub-topic from "Server Events and Client Scripts" topic in PHPMaker Help menu for more information.


saleh
User
Posts: 470

Post by saleh »

But also if the value 0 appears in the table list

// Write your global startup script here
// document.write("page loaded");
<?php
$activated = ew_ExecuteScalar("SELECT Activated FROM programs WHERE Activated = 0 ");
if (CurrentUserLevel() == -2 && CurrentUserLevel()== 0) {
if ($activated == 0)
?>
$("#mi_programs>").hide();
<?php } ?>


mobhar
User
Posts: 11712

Post by mobhar »

Try:

<?php
$activated = ew_ExecuteScalar("SELECT Activated FROM programs WHERE Activated = 0 ");
if ( CurrentUserLevel() == -2 CurrentUserLevel() == 0 $activated == 0 ) {
?>
$("#mi_programs>").hide();
<?php } ?>


saleh
User
Posts: 470

Post by saleh »

The solution I received from PHP Support

The solution works successfully:

// Write your global startup script here
// document.write("page loaded");
<?php
$activated = ew_ExecuteScalar("SELECT Activated FROM programs WHERE Activated = 1 ");
if (CurrentUserLevel() <> 3 && CurrentUserLevel() <> -1) {
if ($activated == 0) {
?>
$("#mi_programs>").hide();
<?php } ?>
<?php } ?> //*** add this line to your code to fix the syntax error.

Thank you to mobhar
Also thank you for the support group phpmaker


Post Reply