How Redfruits ‘draws’ our pages?

Posted: October 23, 2010 in development
Tags: , , , , ,

Redfruits uses Renders to ‘render’ the pages (or others objects) into HTML. Redfruitsh has a default render called ADDefaultRender.

You can create a render from zero, or better to extend the default render. The ADWordpressRender is the more successfully render of the Redfruits’ renders.

For example, with redfruits, you can define a form in this way:

<?php
require_once(REDFRUITS_PATH.'gui/ADCoreGui.php');
$form = new ADForm();
$form->add(new ADLabeledField('Firts name:', new ADTextField('first_name', '', 20, 40)));
$form->add(new ADLabeledField('Last name:', new ADTextField('last_name', '', 20, 40)));
$form->add(new ADSubmit('save', 'save'));

echo $form;
echo $form->render('ADWordpressRender');
?>

Redfruits renders this example in two different formats, as you can see in the next piece of html code:

Default render:

<form  method="post">
<label  for="first_name">Firts name:</label>
<input type="text" id="first_name" name="first_name" value="" size="20" maxlength="40"/>
<label  for="last_name">Last name:</label>
<input type="text" id="last_name" name="last_name" value="" size="20" maxlength="40"/>
<input type="submit" id="save" name="save" value="save"/>
</form>
<div class="wrap"><form  name="frm" id="internalId_0" method="post">

WordPressRender:

<div class="clear"></div>
<table class="form-table">
<tr valign="top">
<th scope="row"><label  for="first_name">Firts name:</label>

</td>
<td><input type="text" id="first_name" name="first_name" value="" size="20" maxlength="40"/></td>
</tr>
<tr valign="top">
<th scope="row"><label  for="last_name">Last name:</label>
</td>
<td><input type="text" id="last_name" name="last_name" value="" size="20" maxlength="40"/></td>
</tr>
</table>

<p class="submit"><input type="submit" id="save" class="button-primary" name="save" value="save"/></p>
</form>
</div>

If you have a web site create with Redfruits, you can change its look by making others renders, or you can create a plugin for WordPress reusing your code.
In next posts we see how to create a WordPress’ plugin with Redfruits, and then, we can see the ‘power’ of the Redfruits’ render for WordPress.

You can see an example in this successfully plugin called TWPCTree. This plugin has a widget to show category trees for custom taxonomies, one of the new features in WordPress 3.0.

Thats’ all for now!!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s