Friday, May 30, 2008

How to add custom stylesheets and javascript

Here was the tutorial on how to do it:

http://framework.weblite.ca/documentation/how-to/custom_javascripts

Basically you just add the code at the delegate class, or application class:


function block__custom_stylesheets()

OR or javascripts:

function block__custom_javascript()


You can also use the dataface application class object which has a function called addHeadContent, and what this does is it will add any thing you enter as a parameter into the slot in the head (the same slot that has the custom stylesheets and javascripts.

For example:


$app =& Dataface_Application::getInstance();
$app->addHeadContent("HELLO");


This will add the words 'HELLO' to the slot section of the html.

The main difference between using this addHeadContent function and the block__custom__stylesheet/javascript function is that you can use the addHeadContent function inside any other function. The block__custom__stylesheet function is isn't own separate function that can't be used in any other function.

But you can do something like this with the addHeadContent function. For example:


function field__recent_offerings(&$record){
$app =& Dataface_Application::getInstance();
$app->addHeadContent("HELLO");
}


So inside of this field function we call the addHeadContent. It has the same effect as the block__custom function, but you can be narrow it down to exactly when you want to include it. Like say you wanted to include the recent_offerings field and you want to apply a custom CSS class to it. You can just call the addHeadContent function.

This is opposed to calling the block_custom function and added the css style there. You would then probably have to add a comment to beside the style sheet there just to remind yourself why this style sheet is even in there.

So it's just for convenience sake.

No comments: