This topic is locked

Using Code Snippets on List page

3/6/2009 5:02:31 AM
PHPRunner General questions
M
marke author

Hi
I want to include some custom function buttons for each row on the list page - the functions call various php functions using a decorated URL e.g. ../refresh.php?seriesCode=AUTUMN09 - where AUTUM09 is a value of a field shown on the list page.
I can do this now by placing the button code directly in the page using the Visual Editor. However I would really much prefer to use an inserted code snippet or custom view format as these are not lost when the page has to be reset. I don't like using the custom view formatiing as I need several buttons on each row all using the same fields and I would need to create dummy fields in the database to handle all the buttons.
When using the code snippet approach - which would be the best solution - I can't find a way of accessing the database fields inside the snippet for each row. I have tried making everything I can think of global using an event and then trying to access it inside the snippet function; but nothing seems to work. I can get access to the data in the final row, but not to the individual row contents. I have though about trying to get the values into session variables - but I have the same problem with knowing which variables to set and in which event.
Does anybody have a general solution for doing this that doesn't get lost every time the page needs to be reset.
thanks for your help
Mark

J
Jane 3/6/2009

Hi,
the one of easiest way to create button for each row is to add aliases to your SQL query on the Edit SQL query tab.

Here is a sample:

select field1,

field2,

field2 as field2_button,

...

from TableName


Then set up field2_button as Custom on the "View as" settings dialog on the Visual Editor tab and use following code:

$value = "<input type=button class=button value=Button1 onclick=\"window.location.href='refresh.php?seriesCode=".$value."';\">";

M
marke author 3/6/2009

Thanks Jane - nice trick
I assume the customisation applied to field2_button doesn't then get applied to field2?
Mark

J
Jane 3/6/2009

Mark,
yes, field2 and field2_button is independent fields in the PHPRunner project.