Page 1 of 1
Custom Field in Images - how to show in frontend?
Posted: 03 Jan 2014, 10:16
by kiscompany
Hello and Happy New year to everybody!
I've created 2 new fields named author and author contact as follows:
1. Add two new columns in phocagallery table with the same names;
2. Add them to array in administrator/.../views/...edit.php
3. Change the phocagalleryimg.xml
Now I have two new fileds in Administrator - Images and when I fill the fields with information it appears in the database correct.
My QUESTION:
How to show this information in the frontend? I want the data of the name of the author and contact to appear after the name of the image.
What files do I need to change and how?
Thank you in advance!
Jenny
Re: Custom Field in Images - how to show in frontend?
Posted: 03 Jan 2014, 17:15
by Jan
Hi, see:
components/com_phocagallery/views/category/tmpl/...
of course you need to load the data from database, so you need to change the frontend model of the category view too and maybe its view:
components/com_phocagallery/views/category/view.html.php
Jan
Re: Custom Field in Images - how to show in frontend?
Posted: 05 Jan 2014, 10:27
by kiscompany
Thank you so much.
To complete the task I've changed the file default_images.php, putting it in template override folder, adding these rows for my custom fileds author and authorcontact:
if($value->type == 2){
if($value->author){
echo '<div class="pg-author" style="font-size:'.$this->tmpl['fontsizeimgdesc'].'px">'.JText::_('COM_PHOCAGALLERY_AUTHOR').': '.$value->author.'</div>';
}
if($value->authorcontact){
echo '<div class="pg-authorcontact" style="font-size:'.$this->tmpl['fontsizeimgdesc'].'px">'.JText::_('COM_PHOCAGALLERY_EMAIL').$value->authorcontact.'</div>';
}
}
To add the new custom fields in front-end upload form for category:
Changes in the default_uploadform.php
<tr>
<td><?php echo JText::_( 'COM_PHOCAGALLERY_AUTHOR' ); ?>:</td>
<td>
<input type="text" id="phocagallery-upload-author" name="phocagalleryuploadauthor" value="" maxlength="255" class="comment-input" />
</td>
</tr>
<tr>
<td><?php echo JText::_( 'COM_PHOCAGALLERY_EMAIL' ); ?></td>
<td>
<input type="text" id="phocagallery-upload-authorcontact" name="phocagalleryuploadauthorcontact" value="" maxlength="255" class="comment-input" />
</td>
</tr>
Re: Custom Field in Images - how to show in frontend?
Posted: 06 Jan 2014, 18:37
by Jan
Ok
Re: Custom Field in Images - how to show in frontend?
Posted: 01 Feb 2014, 19:36
by voytek007
Hi Jenny (kiscompany)!
I can't believe it... You've managed to implement a new feature that I also desperately need since a pretty long time... Is there any way you can email me the modified files? I mean, I could even pay for this modification, donate or something. Would you be so kind? My software versions are Joomla 3 and Phoca Gallery 4.1.0
It would be great to get it to work for the image details view - a link to user profile instead of his name only and the most important thing: "Contact Author" link that allows to send a message to that particular user.
Please let me know... Thanks
Voytek
Re: Custom Field in Images - how to show in frontend?
Posted: 02 Feb 2014, 19:25
by voytek007
Hi Jenny/Jan,
This is a wonderful idea and I need it so much too! I started working on modifications but the only thing that works for me so far is the database (new columns) and new fields in admin panel.
Still no luck with the rest of stuff. I only managed to add those extra "author" and "authorcontact" fields in user panel (frontend) but when filling them out and trying to save that extra data the form says "Item saved" but nothing changes in the database this time. I think I may be missing some other php code in other file or something...
So I just want to be able to save data from frontend "upload" and also from "edit image" panels in case the author of an image forgot to provide that information during first upload - however, in my opinion, the best option here would be to set those fields as "mandatory" (unfortunately setting NOT NULL in database didn't work for me).
And, of course, the last thing that I couldn't get to work is displaying all those information next to image in "detail view" (frontend).
I'm afraid I don't have the knowledge to finish this task so please guys could you help me with this?
Thanks...
Voytek
Re: Custom Field in Images - how to show in frontend?
Posted: 10 Feb 2014, 20:03
by kiscompany
Hello Voytek,
I am sorry I didn't answer you in the forum, but I haven't seen your post there.
I will be happy if my files help you, so please find them attached and sent by email (I might be silly, but couldn't find attachments in this forum, sorry). The original files are there as well. The folder "category" should be in the override template place (/templates/your_template/html/com_phocagallery/category).
Don't forget please that you have to change the code described in the forum having in mind your own custom fields names.
Unfortunately I can't remember Joomla version and Phoca Gallery Version, but I hope you will manage to apply the changes.
Kind Regards,
Jenny