modify category_items.php on template

More
13 years 3 months ago #29412 by bobthebob01
Hi,

I'm having a similar issue. I don't know what is wrong as i built site before with flexicontent and never has that issue.
I have a feeling it's something stupid but since i've looking for hours now, my only solution is to ask here.

here are my spec:
joomla 2.5.7
FLEXIcontent: version 2.0.0 RC9 (r1514) . The problem was happening with previous RC of version 2.0.0

I've checked other templates to check base my code on but i still get some problem.
I've duplicated an existing template and renamed it.
I've assigned field position in the category.xml file and assigned my field via the template page of the backend.

On my category view that list all items (category_items.php), i've cleaned up so i only have what i need as follow:
Code:
<?php /** * @version 1.5 stable $Id: category_items.php 1033 2011-12-08 08:58:02Z enjoyman@gmail.com $ * @package Joomla * @subpackage FLEXIcontent * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr * @license GNU/GPL v2 * * FLEXIcontent is a derivative work of the excellent QuickFAQ component * @copyright (C) 2008 Christoph Lukes * see www.schlu.net for more information * * FLEXIcontent is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ defined( '_JEXEC' ) or die( 'Restricted access' ); // first define the template name $tmpl = $this->tmpl; ?> <?php $items = & $this->items; ?> <?php foreach ($items as $item) : ?> <div class="board-member-item"> <?php if (isset($items[$i]->positions['board-member-picture'])) : ?> <div class="board-member-item-picture"> <?php foreach ($items[$i]->positions['board-member-picture'] as $field) : ?> <?php echo $field->display; ?> <?php endforeach; ?> </div> <?php endif; ?> <div class="board-member-item-description"> <h2><?php echo $item->title; ?></h2> <?php if (isset($items[$i]->positions['description'])) : ?> <?php foreach ($items[$i]->positions['description'] as $field) : ?> <?php echo $field->display; ?> <?php endforeach; ?> <?php endif; ?> </div> </div> <?php endforeach; ?>

but the only value that displays is the $item->title but other from positions are not displaying. Instead i see a noticed on the frontend upon refresh:

Notice: Undefined variable: i in /Applications/MAMP/htdocs/XXXXX/components/com_flexicontent/templates/board-member/category_items.php on line 28
which is where the "board-picture" is supposed to show up.

and
Notice: Undefined variable: i in /Applications/MAMP/htdocs/XXXXX/components/com_flexicontent/templates/board-member/category_items.php on line 37
Which is where the description should display.

Am i am doing wrong? I'm clueless.

Any help would be very appreciated as i've been banging my head for a while now.

Please Log in or Create an account to join the conversation.

More
13 years 3 months ago #29413 by ggppdk
variable $i does not exist, maybe change

<?php foreach ($items as $item) : ?>

to

<?php foreach ($items as $i => $item) : ?>


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
13 years 3 months ago #29416 by bobthebob01
Thanks again ggppdk!

after reading your answer, i figured that i was doing something wrong from the beginning as i was not using $i at first.
Although your trick worked, i wanted to use the template "normally" if i should say.
And voila! it's working exactly as it should:
Code:
<?php /** * @version 1.5 stable $Id: category_items.php 1033 2011-12-08 08:58:02Z enjoyman@gmail.com $ * @package Joomla * @subpackage FLEXIcontent * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr * @license GNU/GPL v2 * * FLEXIcontent is a derivative work of the excellent QuickFAQ component * @copyright (C) 2008 Christoph Lukes * see www.schlu.net for more information * * FLEXIcontent is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ defined( '_JEXEC' ) or die( 'Restricted access' ); // first define the template name $tmpl = $this->tmpl; JFactory::getDocument()->addScript( JURI::base().'components/com_flexicontent/assets/js/tabber-minimized.js'); JFactory::getDocument()->addStyleSheet(JURI::base().'components/com_flexicontent/assets/css/tabber.css'); ?> <?php $items = & $this->items; ?> <?php foreach ($items as $item) : ?> <div class="board-member-item"> <div class="board-member-item-picture"> <?php if (isset($item->positions['board-member-picture'])) : ?> <?php foreach ($item->positions['board-member-picture'] as $field) : ?> <?php echo $field->display; ?> <?php endforeach; ?> <?php endif; ?> </div> <div class="board-member-item-description"> <?php if ($this->params->get('show_title', 1)) : ?> <h2><?php echo $item->title; ?></h2> <?php endif; ?> <?php if (isset($item->positions['description'])) : ?> <?php foreach ($item->positions['description'] as $field) : ?> <?php echo $field->display; ?> <?php endforeach; ?> <?php endif; ?> </div> </div> <?php endforeach; ?>

I guess i was just doing it wrong at first or mistyped something, or mix both ways.
Anyhow, it's working fine now.

You're a champ!

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago #31800 by MikeSantana
<?php if ($blog_field_author_id = $blog_item->fields->item_id) : ?>
<?php $blog_field_author_id = $blog_item->fields->id;
$blog_item_author_id = $blog_item->fieldvalues[$blog_field_author_id][0];
$author_itemmodel = new FlexicontentModelItems();
$author_item = $author_itemmodel->getItem($blog_item_author_id, $check_view_access=false);
FlexicontentFields::getFieldDisplay($author_item,'headshot_photo');
$author_blog_image = $author_item->fields->display;
/* The $author_blog_image has the respective html to display the image related to the author */

HERE is where i need to insert the "author_blog_image" to the same position where "author_profile" is.
Here is a dump of my positions.
[array] positions
[stdClass object] before-description
Properties
[stdClass object] author_profile
[string] display = "Authors Blog02"
[string] id = "81"
[string] label = ""
[string] name = "author_profile"


I would like it to add a new object to the position in order to display it only in the front end not backend.

[stdClass object] author_profile_image
[string] display = "<img src=" dev.mysite.com/images/stories/flexicontent/m_author_blog02.png " alt="Author Blog02" class="fc_field_image">"
[string] id = "8672"
[string] label = ""
[string] name = "author_blog_image"


This Is my code to render each position (in this case "before-description")

if (isset($blog_item->positions)) : ?>
<div class="lineinfo">
<?php foreach ($blog_item->positions as $field) : ?>
<span class="element">
<div class="blog_item_author">'
<?php if ($field->label) : ?>
<span class="label field_<?php echo $field->name; ?>"><?php echo $field->label; ?></span>
<?php endif; ?>
<span class="value field_<?php echo $field->name.'_img'; ?>"><?php echo $author_blog_image; ?></span>
</div>
<?php // endif; ?>
</span>
<?php endforeach; ?>
</div>
<?php endif; ?>

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago #31805 by ggppdk
Hello,

i am not sure of what you are asking,

maybe instead of pasting code, that needs studying in order for me to answer you (note custom development assistant for free is not possible, although commons questions are answered and add to our FAQ articles !!),

-- please first describe what you are trying to do in more details


1. you want to modify the template positions via PHP code in category_items.php ?

2. so that that the code that outputs field's HTML will use it and display it in a specific position?


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save