I've only been using FC for two days, but compared to K2, jSeblod or the likes, it's been awesome.
Only one disappointment so far, it's been the handling of images. We're always re-coding all templates, so an easy way to get image URLs is absolutely crucial.
I fixed this by implementing a small change in the images plugin. See below.
I'd commit this to SVN, but we use Git - and to be honest, I'm not that much of a coder - so I'll "release" the fix here, and maybe some of you gets inspired enough to commit this. I hope so - the image plugin is very important to make FC stand out as a CCK.
Basically, what I did was to insert three more variables to the image object: "small", "medium" and "large". These gives you the URL. Ideally, I should've made these arrays, so that you could get ->small["url"], ->medium["width"] or whatever. That'll be later.
The change is in the
image.php plugin, in the
onDisplayFieldValue function. I inserted the following before the
// first condition is for the display for the preview feature-comment:
Code:
// Add clean display params for the three image sizes.
// These are available as ->small ->medium or ->large from the image object.
$field->{"small"} = JURI::base() . $srcs;
$field->{"medium"} = JURI::base() . $srcm;
$field->{"large"} = JURI::base() . $srcb;
After the change, my
onDisplayFieldValue function looks like this:
Code:
function onDisplayFieldValue(&$field, $item, $values=null, $prop='display')
{
// execute the code only if the field type match the plugin type
if($field->field_type != 'image') return;
global $mainframe, $multiboxadded;
jimport('joomla.filesystem');
$values = $values ? $values : $field->value;
// some parameter shortcuts
$usepopup = $field->parameters->get( 'usepopup' ) ;
$popuptype = $field->parameters->get( 'popuptype', 1 ) ;
if ($values && $values[0] != '')
{
$document = & JFactory::getDocument();
if ($usepopup && $mainframe->isSite() && ($popuptype == 1))
{
if (!$multiboxadded) {
// Multibox integration
$document->addStyleSheet('components/com_flexicontent/librairies/multibox/multibox.css');
$csshack = '
<!--[if lte IE 6]>
<style type="text/css">
.MultiBoxClose, .MultiBoxPrevious, .MultiBoxNext, .MultiBoxNextDisabled, .MultiBoxPreviousDisabled {
behavior: url('.'components/com_flexicontent/librairies/multibox/iepngfix.htc);
}
</style>
<![endif]-->
';
$document->addCustomTag($csshack);
JHTML::_('behavior.mootools');
$document->addScript('components/com_flexicontent/librairies/multibox/js/overlay.js');
$document->addScript('components/com_flexicontent/librairies/multibox/js/multibox.js');
$box = "
var box = {};
window.addEvent('domready', function(){
box = new MultiBox('mb', {descClassName: 'multiBoxDesc', useOverlay: true});
});
";
$document->addScriptDeclaration($box);
$multiboxadded = 1;
}
}
$i = 0;
foreach ($values as $value)
{
$value = unserialize($value);
$path = JPath::clean(JPATH_SITE . DS . $field->parameters->get('dir') . DS . 'l_' . $value['originalname']);
$size = getimagesize($path);
$hl = $size[1];
$wl = $size[0];
$title = isset($value['title']) ? $value['title'] : '';
$alt = isset($value['alt']) ? $value['alt'] : '';
$desc = isset($value['desc']) ? $value['desc'] : '';
$srcs = $field->parameters->get('dir') . '/s_' . $value['originalname'];
$srcm = $field->parameters->get('dir') . '/m_' . $value['originalname'];
$srcb = $field->parameters->get('dir') . '/l_' . $value['originalname'];
$tip = JText::_( 'FLEXI_FIELD_LEGEND' ) . '::' . $title;
$id = $field->item_id . '_' . $field->id . '_' . $i;
$i++;
$view = JRequest::setVar('view', JRequest::getVar('view', 'items'));
$src = ($view == 'category') ? $srcs : $srcm;
// Add clean display params for the three image sizes. These are available as ->small ->medium or ->large from the image object.
$field->{"small"} = JURI::base() . $srcs;
$field->{"medium"} = JURI::base() . $srcm;
$field->{"large"} = JURI::base() . $srcb;
// first condition is for the display for the preview feature
if ($mainframe->isAdmin()) {
$field->{$prop} = '<img class="hasTip" src="../'.$srcs.'" alt ="'.$alt.'" title="'.$tip.'" />';
}
else if ($usepopup && $popuptype == 1)
{
$field->{$prop} = '
<a href="'.$srcb.'" id="mb'.$id.'" class="mb">
<img class="hasTip" src="'. $src .'" alt ="'.$alt.'" title="'.$tip.'" />
<div class="multiBoxDesc mb'.$id.'">'.($desc ? $desc : $title).'</div>
';
} else if ($usepopup && $popuptype == 2) {
$field->{$prop} = '
<a href="'.$srcb.'" rel="rokbox['.$wl.' '.$hl.']" title="'.($desc ? $desc : $title).'">
<img src="'. $src .'" alt ="'.$alt.'" />
';
} else {
$field->{$prop} = '<img class="hasTip" src="'. $src .'" alt ="'.$alt.'" title="'.$tip.'" />';
}
}
} else {
$field->{$prop} = '';
}
// some parameter shortcuts
}
Hope some of you find this useful!
-tobias