Executing php in a design

Hi,


I am working on a customisable page for our intranet which lets users select content and drag the content modules around the page. I'm storing the users setting in a cookie and using php to read the cookie and display the selected content and the page layout. I have built most of the functionality, but I haven't put the design into Matrix yet coz I'm not sure what the best way to do it is.



One of the guys in our team has run php in a design by using remote content. I also read on the forum that Squiz has been working on an asset that allows php code to execute.



Any ideas?



Cheers,

Geoff


Remote Content is the only way you can bring custom PHP code into matrix. There is no asset being (or will be) developed to run random PHP code.

What you're after probably requires more AJAX than PHP.

Sorry, but this gave me the impression that you were working on a php asset....

What AJAX functionality would you suggest? I have built most of the javascript to handle selecting and arranging content and storing settings, but to initially load the page with the setting applied would require php to process the settings first right? Where does the AJAX come in?

[quote]Sorry, but this gave me the impression that you were working on a php asset…
[right][post=“15599”]<{POST_SNAPBACK}>[/post][/right][/quote]



That asset was deemed too insecure to ever include within MySource Matrix so it was scrapped.

[quote]That asset was deemed too insecure to ever include within MySource Matrix so it was scrapped.
[right][post=“15601”]<{POST_SNAPBACK}>[/post][/right][/quote]



ic :unsure:

[quote]ic  :unsure:
[right][post=“15603”]<{POST_SNAPBACK}>[/post][/right][/quote]



Have you considered rewriting your PHP as a Matrix asset itself?

[quote]Hi,


I am working on a customisable page for our intranet which lets users select content and drag the content modules around the page. I’m storing the users setting in a cookie and using php to read the cookie and display the selected content and the page layout.  I have built most of the functionality, but I haven’t put the design into Matrix yet coz I’m not sure what the best way to do it is.



One of the guys in our team has run php in a design by using remote content. I also read on the forum that Squiz has been working on an asset that allows php code to execute.



Any ideas?



Cheers,

Geoff

[right][post=“15597”]<{POST_SNAPBACK}>[/post][/right][/quote]



Hi Geoff,



It is possible to show/hide/move content and save it on a per user basis with a cookie using javascript.



This book has one of the better tutorials I’ve seen.



cheers,



Richard

You are trying to implement a portlet-based system - like Google Home page. The complexity you run into with matrix is based in your assumption that it must be ONE asset that serves all the components based on a certain value stored in the cookie. What you must do is have one asset be responsible for creating content for one block. Then with a lot of AJAX you pull the necessary bits into the page. So most of the processing will be done on the browser side. When page is loaded, the browser would generate the placeholders for all the data using JS, then AJAX calls would populate the boxes from matrix.


Because you cannot rely on cookies being permanently stored, you can save your 'magic' cookie value that stores the state of all the portlets into the metadata value assigned to the current user (if not public). Saving of that value can also be done using AJAX.



Please do not ask for a step-by-step procedure as I have none. Above is the approach I would take when developing a system that you describe.



Fun but not easy.

[quote]You are trying to implement a portlet-based system - like Google Home page. The complexity you run into with matrix is based in your assumption that it must be ONE asset that serves all the components based on a certain value stored in the cookie. What you must do is have one asset be responsible for creating content for one block. Then with a lot of AJAX you pull the necessary bits into the page. So most of the processing will be done on the browser side. When page is loaded, the browser would generate the placeholders for all the data using JS, then AJAX calls would populate the boxes from matrix.


Because you cannot rely on cookies being permanently stored, you can save your 'magic' cookie value that stores the state of all the portlets into the metadata value assigned to the current user (if not public). Saving of that value can also be done using AJAX.



Please do not ask for a step-by-step procedure as I have none. Above is the approach I would take when developing a system that you describe.



Fun but not easy.[/quote]



Thank for that Andrei. It's the most likely option I was considering. I was hoping that there was a way to dynamically build the "portlets" as nested content based on the users cookie settings, but it sounds like that's not going to be an option. I'll start building this in Matrix early next week so you will probably hear from me again then.


I'm not sure what you mean but it sounds interesting.....How would I go about doing this?

[quote]I’m not sure what you mean but it sounds interesting…How would I go about doing this?
[right][post=“15620”]<{POST_SNAPBACK}>[/post][/right][/quote]



Well, Matrix is written in PHP … so create a “Portal” asset in Matrix that essentially has a bunch of nested content divs that users can move around using AJAX. Check the Developer Tutorial over on the Matrix website at: http://matrix.squiz.net/developer/tutorials


Yes, that's what I am doing, but I need Matrix to read from the cookie which content blocks (assets) to display, and then load them in the right place. How would this be done with a bunch of nested content divs?

[quote]Yes, that’s what I am doing, but I need Matrix to read from the cookie which content blocks (assets) to display, and then load them in the right place. How would this be done with a bunch of nested content divs?
[right][post=“15642”]<{POST_SNAPBACK}>[/post][/right][/quote]



You would need to write the cookie reading code into the printBody() function of your custom asset, I suspect. Then, your asset would print out its content based on the cookie data.