Keyword

[SOLVED] "Title Row 2" Extra Field not display in Category

  • Timothy Michel
  • Timothy Michel's Avatar Topic Author
  • Offline
  • Senior Member
More
10 years 2 months ago - 10 years 2 months ago #130099 by Timothy Michel
I created an Extra field called "Title Row 2" and wanted it to display in item.php and category_item.php

Here is the code I added to item.php.
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
<!-- Item article Title Row 2 extra field -->
        <?php foreach ($this->item->extra_fields as $key=>$extraField): ?>               
                <?php if($extraField->name != '' && $extraField->name == 'Title Row 2'): ?>         
                        <h2 class="itemTitleRow2"><?php echo $extraField->value; ?></h2>
                <?php endif; ?>
        <?php endforeach; ?>
<?php endif; ?>                   
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
<!-- Item article SubTitle 1 extra field -->              
        <?php foreach ($this->item->extra_fields as $key=>$extraField): ?>               
                <?php if($extraField->name != '' && $extraField->name == 'Subtitle 1'): ?>
                        <h3 class="itemSubTitle1"><?php echo $extraField->value; ?></h3>
                <?php endif; ?>
        <?php endforeach; ?>
<?php endif; ?>
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
<!-- Item article SubTitle 2 extra field -->
        <?php foreach ($this->item->extra_fields as $key=>$extraField): ?>               
                <?php if($extraField->name != '' && $extraField->name == 'Subtitle 2'): ?>          
                                <h4 class="itemSubTitle2"><?php echo $extraField->value; ?></h4>
                <?php endif; ?>
        <?php endforeach; ?>
<?php endif; ?>   

I only wanted subtitles to display in item view so I added the following to category_item view
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
<!-- Item article Title Row 2 extra field -->
        <?php foreach ($this->item->extra_fields as $key=>$extraField): ?>               
                <?php if($extraField->name != '' && $extraField->name == 'Title Row 2'): ?>         
                        <h3 class="itemTitleRow2"><?php echo $extraField->value; ?></h3>
                <?php endif; ?>
        <?php endforeach; ?>
<?php endif; ?>

The extra title row and the subtitles display fine in item.php view, but they don't display in category_item view and I can't see a reason why they don't.

Oh yes, I took care to filter out "Title Row 2," "Subtitle 1," and "Subtitel 2" in the foreach loop where Extra Fields are normally displayed.

What am I missing here.

You can see the results for the item view at: Behind The Smoke Curtain:

You can see the non-results for Category Item view at: Latest News

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 2 months ago #130100 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: "Title Row 2" Extra Field not display in Category
I think you approached this the wrong way.
I think since you already filtered out your loop you should directly render these extrafields.

This post will help you getk2.org/community/English-K2-Community/171284-Where-to-edit-K2-after-Item-Fields

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Timothy Michel
  • Timothy Michel's Avatar Topic Author
  • Offline
  • Senior Member
More
10 years 2 months ago #130101 by Timothy Michel
Replied by Timothy Michel on topic Re: "Title Row 2" Extra Field not display in Category
I can't get past the spam filter right now, so please reed the attached text file.

But Thanks, the suggestion you make helped streamline the code considerably, but I am still having the same problem with category_item.php.

See attached:

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 2 months ago #130102 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: "Title Row 2" Extra Field not display in Category
Make sure you have used $this->item and $item where appropriate.
A look at your file will tell you which one to use.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Timothy Michel
  • Timothy Michel's Avatar Topic Author
  • Offline
  • Senior Member
More
10 years 2 months ago - 10 years 2 months ago #130103 by Timothy Michel
Replied by Timothy Michel on topic Re: "Title Row 2" Extra Field not display in Category
OK the following works in item.php:
<?php if($this->item->params->get('itemTitle')): ?>
<!-- Item title -->
        <h2 class="itemTitle">
                <?php if(isset($this->item->editLink)): ?>
                        <!-- Item edit link -->
                        <span class="itemEditLink">
                                <a class="modal" rel="{handler:'iframe',size:{x:990,y:550}}" href="<?php echo $this->item->editLink; ?>">
                                        <?php echo JText::_('K2_EDIT_ITEM'); ?>
                                </a>
                        </span>
                <?php endif; ?>

                <?php echo $this->item->title; ?>
        </h2>
<?php endif; ?>                   
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
        <!-- Item article Title Row 2 extra field -->             
        <?php if(isset($this->item->extraFields->titleRowTwo->value)): ?>             
                <h2 class="itemTitleRow2"><?php echo $this->item->extraFields->titleRowTwo->value; ?></h2>
        <?php endif; ?>
        <!-- Item article SubTitle 1 extra field -->                      
        <?php if(isset($this->item->extraFields->subtitleOne->value)): ?>
                <h3 class="itemSubTitle1"><?php echo $this->item->extraFields->subtitleOne->value; ?></h3>
        <?php endif; ?>                   
        <!-- Item article SubTitle 2 extra field -->      
        <?php if(isset($this->item->extraFields->subtitleTwo->value)): ?>             
                <h4 class="itemSubTitle2"><?php echo $this->item->extraFields->subtitleTwo->value; ?></h4>
        <?php endif; ?>
<?php endif; ?>

See: Behind the Smoke Curtain: The 9/11 Pentagon Attack

But in category_item.php, following doesn't:
<?php if($this->item->params->get('catItemTitle')): ?>
        <!-- Item title -->
        <h3 class="catItemTitle">
        <?php if(isset($this->item->editLink)): ?>
                <!-- Item edit link -->
                <span class="catItemEditLink">
                        <a class="modal" rel="{handler:'iframe',size:{x:990,y:550}}" href="<?php echo $this->item->editLink; ?>">
                                <?php echo JText::_('K2_EDIT_ITEM'); ?>
                        </a>
                </span>
        <?php endif; ?>

        <?php if ($this->item->params->get('catItemTitleLinked')): ?>
                <a href="<?php echo $this->item->link; ?>">
                        <?php echo $this->item->title; ?>                                           
                </a>
        <?php else: ?>
                <?php echo $this->item->title; ?>                                           
        <?php endif; ?>
        </h3>                     
<?php endif; ?>
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
        <!-- Item article Title Row 2 extra field -->             
        <?php if(isset($this->item->extraFields->titleRowTwo->value)): ?>
                <h3 class="catItemTitle">                       
                        <?php echo $this->item->extraFields->titleRowTwo->value; ?>
                </h3>
        <?php endif; ?>
<?php endif; ?>                   

I don't understand the distinction between $this-> item and $item. Isn't item a variable or method of $this, the current object? We are drilling into the database, so that the drill down proceeds from $this, the current object; which changes depending on what it is wrapped in?. Nevertheless, it would seem to me that if the code works in item.php, it should work in category_item.php as the file is not a wrapper. I have separated the titleRowTwo part from the title to simplify the code so that I can eliminate anything extraneous. As soon as I get titleRowTwo to display I will nest it back into catItemTitle.

Again the problem is viewable at: Behind the Smoke Curtain:

Only "title" is displaying and not both "title" and "titleRowTwo"

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 2 months ago #130104 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: "Title Row 2" Extra Field not display in Category
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>

this is to blame. The params->get is wrong. It refers to the item's settings not the category ones.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Timothy Michel
  • Timothy Michel's Avatar Topic Author
  • Offline
  • Senior Member
More
10 years 2 months ago - 10 years 2 months ago #130105 by Timothy Michel
Replied by Timothy Michel on topic Re: "Title Row 2" Extra Field not display in Category
Wow Krikor, your awesomeness is overflowing. That's the context of $this.

Muchos gracias.

What is the category reference to the extra fields, is it "catItemExtraFields." OK I am going to have to do a little background work to learn how to reference this.

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

  • Timothy Michel
  • Timothy Michel's Avatar Topic Author
  • Offline
  • Senior Member
More
10 years 2 months ago - 10 years 2 months ago #130106 by Timothy Michel
Replied by Timothy Michel on topic Re: "Title Row 2" Extra Field not display in Category
I hate to say this, but I am just not getting this.

Here is what I have:
<?php if($this->item->params->get('catItemTitle')): ?>
  <!-- Item title -->
  <h3 class="catItemTitle">
    <?php if(isset($this->item->editLink)): ?>
      <!-- Item edit link -->
      <span class="catItemEditLink">
        <a class="modal" rel="{handler:'iframe',size:{x:990,y:550}}" href="<?php echo $this->item->editLink; ?>">
          <?php echo JText::_('K2_EDIT_ITEM'); ?>
        </a>
      </span>
    <?php endif; ?>
    <?php if ($this->item->params->get('catItemTitleLinked')): ?>
      <a href="<?php echo $this->item->link; ?>">
        <?php echo $this->item->title; ?>
        <?php if($this->item->params->get('catItemExtraFields') && count($this->item->extra_fields)): ?>
          <?php if(isset($this->item->extraFields->titleRowTwo->value)): ?>
            <br /><?php echo $this->item->extraFields->$titleRowTwo->value; ?>
          <?php endif; ?>
        <?php endif; ?>
      </a>
    <?php else: ?>
      <?php echo $this->item->title; ?>
        <?php if($this->item->params->get('catItemExtraFields') && count($this->item->extra_fields)): ?>
          <?php if(isset($this->item->extra_fields->$titleRowTwo->value)): ?>
            <br /><?php echo $this->item->extra_fields->$titleRowTwo->value; ?>
          <?php endif; ?>
        <?php endif; ?>                                           
      <?php endif; ?>
    </h3>                     
<?php endif; ?>

My thinking is that there is no object
$catItemTitle->item->params->get('catItemExtraFields')
that $this->item->params->get('catItemExtraFields') would imply.

I have to get this done, but I am not gaining any insights. Any additional help will be very appreciated.

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

  • Timothy Michel
  • Timothy Michel's Avatar Topic Author
  • Offline
  • Senior Member
More
10 years 2 months ago #130107 by Timothy Michel
Replied by Timothy Michel on topic Re: "Title Row 2" Extra Field not display in Category
Have no idea why, but the Extra Field "titleRowTwo" started displaying under the title in CategoryItem view where it should have. Don't know what changed, it just started working.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 2 months ago #130108 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: "Title Row 2" Extra Field not display in Category
It was probably working from your last edit, but you were viewing cached content.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum