I am adding a component to a site that is using Community Builder. The possibilities for displaying lists and profiles in CB are quite limited so I am building a component with J-Cook to display a couple of customised lists depending on the type of user logged on.
After installing the component generated with J-Cook, I just changed the table name to #__comprofiler (which is where CB stores member information) and it works brilliantly.
The only tricky bit is to display images. Community builder is storing images by saving the file name in a field called avatar and the actual image file is stored in images/comprofiler.
To display an image in a form, I use the following code:
echo JDom::_('html.fly.file.default', array(
'dataKey' => 'avatar',
'dataObject' => $this->comprofilerform,
'width' => 'auto',
'height' => 'auto',
'attrs' => array('format:png'),
'indirect' => true,
'root' => JPATH_SITE.'/images/comprofiler/'
));
This is the J-Cook generated code with the 'root' parameter changed. This generates the correct html code, bit for some reason, the image does not display on my site. It works on a freshly installed empty Joomla site but not on the one I am working on. I have tried to play around with cache settings etc, but I haven't found anything that works.
To work around the problem, I tried changing the 'indirect' parameter to false. A direct link to the image works, but it seems that the Jdom function doesn't include the path to the image when the indirect parameter is set to false.
So the above code with indirect set to true generates this html with the correct path:
<div class="img-zone" style="width:264px;height:348px; overflow:hidden;display:inline-block;">
<img width="264px" height="348px" style="" src="/gpc2/index.php?option=com_mbrs&task=file&attrs=format:png&path=/var/www/gpc2/images/comprofiler/65_4ff9f48d13755.jpg">
</div>
and with the indirect set to false, this
<div class="img-zone" style="width:264px;height:348px; overflow:hidden;display:inline-block;">
<img width="264px" height="348px" style="" src="/gpc2/65_4ff9f48d13755.jpg">
</div>
As you can see, the path is different. With the indirect set to false, the images/comprofiler bit is missing and it will look in gpc2 which is the root directory for the application.
So I have two questions:
1. Has anyone else had site-specific problems displaying images with Jdom and how did you fix it?
2. Is Jdom really meant to generate that path when indirect is set to false? I can't see how that could work.
Grateful for any help!