This topic is locked

how to disable 'add new' in list

11/8/2006 4:38:03 PM
PHPRunner General questions
F
frocco author

Hello,
In PHPRunner 3.1, I need to disable "Add New" if the master record is closed (value=1)

How can I do this?

I modified the template in PHPRunner 3.0.
Thanks
Frank

Alexey admin 11/9/2006

Frank,
here is what you can do.

  1. Proceed to Visual Editor tab, select "Add new" link with the mouse and switch to HTML mode.

    Insert the following tags before and after the link:
    {if $allow_add}

    <a href="..._add.php" >Add new</a>

    {/if}


Then put this code into List OnLoad event

global $smarty;

if(... master record is closed...)

$smarty->assign("allow_add",false);

else

$smarty->assign("allow_add",true);


If you use User group permissions the {if $allow_add} clause is already there so no actions in Visual Editor are needed.

F
frocco author 11/9/2006

Thank you,

It works great on the child list.

I need to do the same on the master list.

However, there is no event before a row is written or after a row is written.

How can I do this?
Frank

Frank,

here is what you can do.

  1. Proceed to Visual Editor tab, select "Add new" link with the mouse and switch to HTML mode.

    Insert the following tags before and after the link:
    Then put this code into List OnLoad event
    If you use User group permissions the {if $allow_add} clause is already there so no actions in Visual Editor are needed.

F
frocco author 11/13/2006

Is this not possible on the master page.

I do not want to allow edit when the record is closed.
Frank

Thank you,

It works great on the child list.

I need to do the same on the master list.

However, there is no event before a row is written or after a row is written.

How can I do this?
Frank

Alexey admin 11/14/2006

Frank,
you can do this the similar way.
At first enclose add these expressions before and after the Edit link in Visual Editor:

{if $row.1editable}

...

{/if}


Build the pages.
Open generated ..._list.php file with a text editor

Find this line there:

$rowinfo[]=$row;



and insert this code just before it:

if(...closed ?...)

$row["1editable"] = false;

else

$row["1editable"] = true;



use $data["Fieldname"] expressions to access field values there.

F
frocco author 11/14/2006

Thanks for the help.

I will give that a try.
Will there be more events added?

I was hoping to do this without having to modify the generated source.
Regards,
Frank

Frank,

you can do this the similar way.
At first enclose add these expressions before and after the Edit link in Visual Editor:
Build the pages.
Open generated ..._list.php file with a text editor

Find this line there:
and insert this code just before it:
use $data["Fieldname"] expressions to access field values there.