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.

Friday, May 9, 2008

Using the table relationship permissions function

Inside of each delegate class, we can use the function rel_nameOfRelationship__permissions(&$record) to specify the permissions on that relationship. The reason this works is because when we click on a tab to go to the relationship we are still in the original table.

For example, say we have a companies table that had a relationship to an offerings table. An offerings tab will be present. You can control the permissions on the tab (as in whether the user can add new offerings) by using that rel_nameOfRelationship__permissions(&$record) function.

In the event, that you want to actually remove that tab from the view, then you need to do this in the relationships.ini file of that table folder. Like this:

[offerings]
__sql__ = "SELECT * FROM offerings WHERE company_id ='$company_id'"
action:condition="isAdmin() or ($record->val('company_id') == getCompanyID()) or ( isBrokerDealer() and $record->val('company_id') == getDealerID())"
actions:addexisting=0
action:label="offerings"
section:sort="date_reported desc


  1. The __sql__ is just the SQL statement to retrieve the records

  2. action:condition is the part that determines whether the tab should appear or not.

  3. actions:addexisting makes it so that the add existing option doesn't appear



I found this strange bug (not sure if it is a bug). But if the try to enter action:condition = 0 just by itself it won't hide the tab. You have to enter action:condition = "false" in order for it to work...

Tuesday, May 6, 2008

Setting up Drupal Editing in Eclipse

Found a cool article that teaches us how to setup Drupal editing inside of Eclipse. Pretty cool actually.

The idea of adding like extra content types for a language can probably be extended for future use.