21310 Posts in 5739 Topics by 2604 members
General Questions
SilverStripe Forums » General Questions » Is it possible to generate page type properties in a function?
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 621 Views |
-
Is it possible to generate page type properties in a function?

3 August 2011 at 2:04am
I have a page type that, at times, my client has wanted me to update the amount of rows and columns that are available to add content into. Rather than having to manually add more page properties I want to run a function that takes a row and column amount to append the static $db variable. Is there a scope in which I can run this function so that the reflection on the $db variable can still take place?
-
Re: Is it possible to generate page type properties in a function?

3 August 2011 at 2:52am
Hi Matt,
It is possible to read the php file, modify it, write it back to disk and then trigger a dev/build -sure.
"self-modifying" code is seen as a bad practice - I'd say it was because the code could wipe itself out and damage the system. This is because code can have mistakes, when it modifies itself with a mistake it would be magnified. "automatic programming" on the other hand (using software to create software) would be much better... I'm looking forward to SilverSmith by UncleCheese (http://www.leftandmain.com/silverstripe-screencasts/2011/04/11/the-silversmith-framework-code-right-type-less-build-fast/)- shouldn't be long now...
Barry
-
Re: Is it possible to generate page type properties in a function?

3 August 2011 at 7:14pm
Yeah editing the code = bad idea. You should take a look at your data model, if you need to create multiple instances of the same thing then you should be looking to create a has_many relationship or splitting out those fields to another object that you can repeat.
-
Re: Is it possible to generate page type properties in a function?

5 August 2011 at 3:55am
has_many generally relies on popup editors, does it not?
-
Re: Is it possible to generate page type properties in a function?

5 August 2011 at 9:07am
TableListFields (like the one in 'Security') can also do simple fields inline in the table which works well if you have title -> link type data.
| 621 Views | ||
|
Page:
1
|
Go to Top |



