I have been using the ReadyTheme Content Sections more and they are pretty nifty to keep things neat and tidy. This made me wonder if it might not be possible to create Code Sections and within those code sections define an 'interface' to expose properties, attributes or variables which can then be used from the calling page.
For example say we create a Code Section that did some special customer function, and we want expose values in the interface like so
define interfacelement: customer_type {
.name = privatevariable.customer_name;
.type = privatevariable.customer_type;
.action =rw /* read write */
insert code to lookup customer name and read or assign customer special type i.e. wholesale, b2b
}
Then we could use this in any page or template and pass or read values from this 'black boxed' code. You could change the code however you wanted and wouldn't have to muck with the page/template calling it as long as the interface elements don't change
something like
<mvt:item name="readytheme" param="codesection( 'customer_type' ) action=r,customer_name,customer_type " />
<mvt:item name="readytheme" param="codesection( 'customer_type' ) action=w,johnsmith,b2b" />
what appeals to me is
1-the chance to make the page templates neater and not have a ball of yarn where I'm less likely to change one thing and break some other code unintentionally
2-the ability to separate the code into into discrete reusable functions, that can be edited without affecting the page they are embedded in as long as the interface remains the same.
3-the ability to have someone define the code and interface in a codesection and someone else use that with a simple call -without having to expose them to the code - ie I could pay to have code done, with specific properties or attributes exposed, and even if I can't understand the code I can still use it because I know what values the interface expects.
Hope this makes sense.
For example say we create a Code Section that did some special customer function, and we want expose values in the interface like so
define interfacelement: customer_type {
.name = privatevariable.customer_name;
.type = privatevariable.customer_type;
.action =rw /* read write */
insert code to lookup customer name and read or assign customer special type i.e. wholesale, b2b
}
Then we could use this in any page or template and pass or read values from this 'black boxed' code. You could change the code however you wanted and wouldn't have to muck with the page/template calling it as long as the interface elements don't change
something like
<mvt:item name="readytheme" param="codesection( 'customer_type' ) action=r,customer_name,customer_type " />
<mvt:item name="readytheme" param="codesection( 'customer_type' ) action=w,johnsmith,b2b" />
what appeals to me is
1-the chance to make the page templates neater and not have a ball of yarn where I'm less likely to change one thing and break some other code unintentionally
2-the ability to separate the code into into discrete reusable functions, that can be edited without affecting the page they are embedded in as long as the interface remains the same.
3-the ability to have someone define the code and interface in a codesection and someone else use that with a simple call -without having to expose them to the code - ie I could pay to have code done, with specific properties or attributes exposed, and even if I can't understand the code I can still use it because I know what values the interface expects.
Hope this makes sense.
Comment