Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • lmgsupport Friend
    #834325

    Having a bit of an issue. Following the following articles doesn’t work http://www.t3-framework.org/documentation/extend-com-content.html#add-extra-fields https://www.joomlart.com/tutorials/joomla-tutorials/adding-joomla-custom-fields-in-article-with-t3-framework

    when adding $attribs = new JRegistry($this->item->attribs); to my php file i get a "Fatal error: Using $this when not in object context"

    So far i have

    1. created a my fields in _template/etc/extrafields/tminfo.xml
    2. modified the carousel to fit my layout in _template/html/mod_articlescategory adding the attribute php script seen above and in the documents linked
    3. added the extra field option to the category in joomla
    4. created my article category module and set its layout, module position, category and pages it is visible on.
    5. added an article in the selected category, with it’s content and changed the extra fields.

    Generally that is all you need, but it doesnt work. I noticed that all the $otherinfo items have actually been added to the template helper. What can i do to make this work?

    <?xml version="1.0" encoding="utf-8"?>
    
    <form>
        <fields name="attribs">
    
        <fieldset name="extra-fields" label="Author Information" group="authorinfo">
    
            <field name="auth_name"
                            type="text"           
    
                            default="PCM"
    
                            label="Author Name"
    
                            description="Name of The Author" ></field>
    
            <field name="auth_title"
                            type="text"           
    
                            default="Doctor"
    
                            label="Author Credentials / Job Title"
    
                            description="Any Credentials or Titles for Author" ></field>
    
        </fieldset>
    
    </fields>
    
    </form>

    tm_info.xml

    <?php
    /**
    
     */
    
    // no direct access
    defined('_JEXEC') or die;
    if(isset($item_heading) || $item_heading=='') $item_heading = 4;
    JLoader::register('NuevoHelper',T3_TEMPLATE_PATH.'/templateHelper.php');
    $moduleIntro = $params->get ('module-intro');
    ?>
    <?php  if($moduleIntro) : ?> 
        <div class="module-intro text-center"><?php echo $moduleIntro; ?></div>
    <?php endif; ?>
    <div class="category-module category-carousel <?php echo $moduleclass_sfx; ?>">
    <div id="article-carousel<?php echo $module->id;?>" class="carousel slide col-md-10 col-md-12" data-ride="carousel">
      <div class="carousel-inner">
      <?php $count=0; 
            foreach ($list as $item) : ?>   
            <div class="clearfix item <?php if($count==0): echo 'active'; endif; ?>">
    
                    <div class="article-content">
    
                        <?php if ($params->get('show_introtext')) :?>
                            <p class="mod-articles-category-introtext">
                            <?php echo $item->displayIntrotext; ?><span class="author_info"><span class="author_name bold">  <?php echo $params->get('auth_name') ?></span> / <?php echo $params->get('auth_title') ?> </span>
                            </p>
                        <?php endif; ?>
    
                        <?php if ($params->get('show_readmore')) :?>
                            <p class="mod-articles-category-readmore">
                                <a class="mod-articles-category-title btn btn-link <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
                                <?php if ($item->params->get('access-view')== FALSE) :
                                        echo JText::_('MOD_ARTICLES_CATEGORY_REGISTER_TO_READ_MORE');
                                    elseif ($readmore = $item->alternative_readmore) :
                                        echo $readmore;
                                        echo JHtml::_('string.truncate', $item->title, $params->get('readmore_limit'));
                                    elseif ($params->get('show_readmore_title', 0) == 0) :
                                        echo JText::sprintf('TPL_MOD_ARTICLES_CATEGORY_READ_MORE_TITLE');
                                    else :
                                        echo JText::_('TPL_MOD_ARTICLES_CATEGORY_READ_MORE');
                                        echo JHtml::_('string.truncate', $item->title, $params->get('readmore_limit'));
                                    endif; ?>
                            </a>
                            </p>
                        <?php endif; ?>
                    </div>
        </div>
        <?php $count++; 
        endforeach; ?>
        </div>
      <!-- Controls -->
      <ol class="carousel-indicators">
      <?php 
        for($i=0;$i<count($list);$i++){
            $otherinfo = NuevoHelper::loadParamsContents($list[$i]);
            $inner = $otherinfo['icon_titles']?'<i class="fa '.$otherinfo['icon_titles'].'"></i>':'<i class="fa fa-question"></i>';
            $active = '';
            if($i==0) $active=' class="active"';
            echo '<li data-target="#article-carousel'.$module->id.'" style="width : '.(100/count($list)).'%" data-slide-to="'.$i.'"'.$active.'><span class="title">'.($otherinfo['short_titles']?$otherinfo['short_titles']:$list[$i]->title).'</span>'.$inner.'</li>';
        }
      ?>
      </ol>
    </div>
    
    </div>
    

    Modified Carousel.php

    Saguaros Moderator
    #834814

    Hi

    You should check out this documentation again and create necessary files for your own extra field: https://www.joomlart.com/tutorials/joomla-tutorials/adding-joomla-custom-fields-in-article-with-t3-framework

    lmgsupport Friend
    #835058

    Saguaros,

    Please read my post again. I have already been to the provided link followed it line for line and it did not work. i get the fatal error.

    thanks

    Saguaros Moderator
    #835802

    It’s added in your new file, right? pls try to add in blog item as mentioned in above link and see how it goes.

    lmgsupport Friend
    #836200

    Maybe i haven’t explained my issues correctly.

    navigate to the ja nuevo demo ja-nuevo.demo.joomlart.com and scroll down to the testimonial section.

    This module is displayed via /templates/ja-nuevo/html/mod_articles_category/carousel.php

    I changed the layout and renamed it testimonials.php

    custom fields in articles with t3 framework tutorial doesn’t work because i’m not working in mod_content/category

    I need to add extra fields other than the ones that were already there. The existing extra fields are referenced in the /template/ja-nuevo/templatehelper.php via

    public static function loadParamsContents($item, $pdata = 'attribs'){
            $data = $item->$pdata;
            if(is_string($pdata)){
                $data = new JRegistry;
                $data->loadString($item->$pdata);
            }
    
            if($data instanceof JRegistry){
                return array(
                    'icon_titles' => $data->get('icon_titles', ''),
                    'short_titles'=>$data->get('short_titles', '')
                );
            }
    
            return array(
                'icon_titles' => '',
                'short_titles'=> ''
            );
        }

    but I really don’t understand that…

    Saguaros Moderator
    #837959

    So you want to add Extra Fields for Articles Category module, not Joomla article.

    The ‘carousel’ module you’re mentioning is module named ‘What makes us different’ as in our demo site and it’s already included Extra Fields, you can change this file instead:

    ROOT/templates/ja_nuevo/etc/form/mod_articles_category.xml

    There are 2 extra fields there: article_column and module-intro, you can add your own extra field there.

    Next, you will get the new extra field for layout of Articles Category module as you want. In our demo site, the ‘carousel’ layout of Articles Category module get the extra field ‘module-intro’, you can check this file to see how it gets the ‘module-intro’ extra field:

    ROOT/templates/ja_nuevo/html/mod_articles_category/carousel.php

Viewing 6 posts - 1 through 6 (of 6 total)

This topic contains 5 replies, has 2 voices, and was last updated by  Saguaros 8 years, 10 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum