2017-11-02 8 views
1

joomla 구성 요소에있는 판매자 스토어에 대한 링크가있는 버튼을 추가하려고하는데 어떻게 할 수 있는지 잘 모릅니다.
내가 필요로하는 PHP 파일에서 코드를 추가하려고하는데 다른 페이지에 추가하는 방법을 모르겠습니다. 누군가가 어떤 방법으로 나를 인도 할 수 있다면 그것은 뛰어날 것입니다.
여기 가게에 대한 링크가있는 페이지입니다 :joomla에서 사용자 ID와 링크를 만들려고합니다

<?php 

// no direct access 
defined('_JEXEC') or die; 

use Joomla\Registry\Registry; 

/** @var SellaciousViewProduct $this */ 
$sellers = $this->item->get('sellers'); 

if (!isset($sellers[0]) || (count($sellers) == 1 && $sellers[0]->seller_uid == $this->item->get('seller_uid'))) 
{ 
    return; 
} 

$c_currency = $this->helper->currency->current('code_3'); 
?> 
<div class="clearfix"></div> 
<a name="also-selling">&nbsp;</a> 
<hr class="isolate"/> 
<h4 class="center"><?php echo JText::_('COM_SELLACIOUS_PRODUCT_HEADING_BLOCK_SELLERS'); ?></h4> 

<table class="product-sellers table table-striped table-hover table-bordered"> 
    <thead> 
    <tr> 
     <th>SELLER  </th> 
     <th>DELIVERY INFO</th> 
     <th>PRICE  </th> 
     <th>ACTION  </th> 
    </tr> 
    </thead> 
    <tbody> 
    <?php 
    foreach ($sellers as $i => $seller) 
    { 
     /** @var Registry $item */ 
     $item  = new Registry($seller); 
     $s_currency = $this->helper->currency->forSeller($item->get('seller_uid'), 'code_3'); 

     // todo: Add this to config (show current one or not in more sellers) and move to model 
     if ($item->get('seller_uid') == $this->item->get('seller_uid')) 
     { 
      continue; 
     } 
     ?> 
     <tr> 
      <td style="width: 220px;" class="nowrap"> 
       <div class="seller-info"> 
        <a href="<?php echo JRoute::_('index.php?option=com_sellacious&view=store&id=' . $item->get('seller_uid')); ?>"> 
         <?php echo $item->get('seller_company', $item->get('seller_name')); ?></a> 
        <?php $rating = $item->get('seller_rating.rating'); ?> 
        <span class="label <?php echo ($rating < 3) ? 'label-warning' : 'label-success' ?>"><?php echo number_format($rating, 1) ?>/5.0</span> 
       </div> 

       <?php if ($item->get('exchange_days')): ?> 
        <?php if ($item->get('exchange_tnc')): 
         $options = array(
          'title' => '<strong>' . (int) $item->get('exchange_days') . ' Days</strong> Replacement Guarantee', 
          'backdrop' => 'static', 
         ); 
         echo JHtml::_('bootstrap.renderModal', 'exchange_tnc-' . $item->get('code'), $options, $item->get('exchange_tnc')); 
        endif; ?> 
        <div class="replacement-info"> 
         <i class="fa fa-refresh"></i> 
         <strong> <?php echo (int) $item->get('exchange_days') ?> Days</strong> Replacement 
         <?php if ($item->get('exchange_tnc')): ?> 
          <a href="#exchange_tnc-<?php echo $item->get('code') ?>" role="button" data-toggle="modal">[<i class="fa fa-question"></i>]</a> 
         <?php endif; ?> 
        </div> 
       <?php endif; ?> 

       <?php if ($item->get('return_days')): ?> 
        <?php if ($item->get('return_tnc')): 
         $options = array(
          'title' => '<strong>' . (int) $item->get('return_days') . ' Days</strong> Easy Return', 
          'backdrop' => 'static', 
         ); 
         echo JHtml::_('bootstrap.renderModal', 'return_tnc-' . $item->get('code'), $options, $item->get('return_tnc')); 
        endif; ?> 
        <div class="replacement-info"> 
         <i class="fa fa-refresh"></i> 
         <strong> <?php echo (int) $item->get('return_days') ?> Days</strong> Easy Return 
         <?php if ($item->get('return_tnc')): ?> 
          <a href="#return_tnc-<?php echo $item->get('code') ?>" role="button" data-toggle="modal">[<i class="fa fa-question"></i>]</a> 
         <?php endif; ?> 
        </div> 
       <?php endif; ?> 

       <div> 
        <?php $allowed_listing_type = (array) $this->helper->config->get('allowed_listing_type'); ?> 
        <?php if (count($allowed_listing_type) != 1): ?> 
        <span class="label label-info margin-top-10">Condition: 
         <?php 
         $list_type = $item->get('listing_type'); 

         // What if this is a not allowed listing type value 
         if ($list_type == 1): 
          echo JText::plural('COM_SELLACIOUS_PRODUCT_FIELD_LISTING_TYPE_VALUE', $list_type); 
         else: 
          $list_cond = $item->get('item_condition'); 
          echo JText::plural('COM_SELLACIOUS_PRODUCT_FIELD_ITEM_CONDITION_VALUE', $list_type * 10 + (int) $list_cond); 
         endif; 
         ?> 
        </span> 
        <?php endif; ?> 
       </div> 
      </td> 
      <td> 
       <div class="delivery-info"> 
        <?php echo JHtml::_('date', '+ ' . rand(1, 30) . ' days', 'D, dS F'); ?> 
        <br> 
        <small><?php 
         $flat_ship = $item->get('flat_shipping'); 
         $ship_fee = $item->get('shipping_flat_fee'); 

         if ($flat_ship == 0) 
         { 
          echo JText::_('COM_SELLACIOUS_PRODUCT_SHIPPING_FEE_IN_CART'); 
         } 
         elseif (round($ship_fee, 2) > 0) 
         { 
          $fee = $this->helper->currency->display($ship_fee, $s_currency, $c_currency, true); 
          echo JText::sprintf('COM_SELLACIOUS_PRODUCT_SHIPPING_FEE_FLAT', $fee); 
         } 
         else 
         { 
          echo JText::_('COM_SELLACIOUS_PRODUCT_SHIPPING_FEE_FREE'); 
         } 
        ?></small> 
       </div> 
      </td> 
      <td style="width:90px;" class="center"> 
       <span class="product-price-sm"><?php 
        echo $this->helper->currency->display($item->get('price.sales_price'), $s_currency, $c_currency, true) ?></span> 
      </td> 
      <td style="width:100px;" class="nowrap"> 
       <?php $link = JRoute::_('index.php?option=com_sellacious&view=product&p=' . $item->get('code')); ?> 
       <a href="<?php echo $link ?>"><button class="btn btn-primary btn-cart-sm">DETAILS</button></a><br/> 
       <button type="button" class="btn btn-warning btn-cart-sm btn-add-cart" data-item="<?php echo $item->get('code') ?>">ДОБАВИ В КОЛИЧКАТА</button> 
       <!--<button type="button" class="btn btn-success btn-cart-sm btn-add-cart" 
          data-item="<?php /*echo $item->get('code') */?>" data-checkout="true">КУПИ СЕГА</button>--> 
      </td> 
     </tr> 
     <?php 
    } 
    ?> 
    </tbody> 
</table> 

을 그리고 이것은 내가 판매자에 링크 부분을 가져 노력하고있어 파일을 저장할 이해

<?php 

// no direct access. 
defined('_JEXEC') or die; 

jimport('sellacious.loader'); 

if (class_exists('SellaciousHelper')) 
{ 
    $helper = SellaciousHelper::getInstance(); 
} 
?> 
<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>"> 

    <head> 
     <meta charset="utf-8"> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> 

     <!-- favicon --> 
     <link rel="shortcut icon" href="templates/sellacious/images/favicon/favicon.ico" type="image/x-icon" /> 
     <link rel="icon" href="templates/sellacious/images/favicon/favicon.ico" type="image/x-icon" /> 

     <?php 
     $user  = JFactory::getUser(); 
     $doc  = JFactory::getDocument(); 
     $app  = JFactory::getApplication(); 
     $sitename = $app->get('sitename'); 

     JHtml::_('script', 'media/com_sellacious/js/plugin/messagebox/jquery.messagebox.min.js', false, false); 
     JHtml::_('stylesheet', 'media/com_sellacious/js/plugin/messagebox/jquery.messagebox.css', null, false); 

     $doc->addStyleSheet('//fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,300,400,700'); 
     $doc->addStyleSheet('templates/sellacious/css/bootstrap.min.css', 'text/css', 'screen'); 
     $doc->addStyleSheet('templates/sellacious/css/font-awesome.min.css', 'text/css', 'screen'); 
     $doc->addStyleSheet('templates/sellacious/css/joomla-icons.css', 'text/css', 'screen'); 

     $doc->addStyleSheet('templates/sellacious/css/smartadmin-production.css', 'text/css', 'screen'); 
     $doc->addStyleSheet('templates/sellacious/css/smartadmin-skins.css', 'text/css', 'screen'); 
     $doc->addStyleSheet('templates/sellacious/css/custom-style.css', 'text/css', 'screen'); 

     if ($this->direction == 'rtl') 
     { 
      $doc->addStyleSheet('templates/sellacious/css/smartadmin-rtl.css', 'text/css', 'screen'); 
     } 

     JHtml::_('jquery.framework'); 
     JHtml::_('bootstrap.tooltip'); 

     $doc->addScript('templates/sellacious/js/libs/jquery-ui-1.10.3.min.js');      // jQuery UI full, not from joomla core's minimised one 
     $doc->addScript('templates/sellacious/js/plugin/fastclick/fastclick.js');     // FastClick: For mobile devices 
     $doc->addScript('templates/sellacious/js/plugin/jquery-touch/jquery.ui.touch-punch.min.js'); // JS TOUCH plugin for mobile drag-drop touch events 
     $doc->addScript('templates/sellacious/js/plugin/msie-fix/jquery.mb.browser.min.js');   // browser msie issue fix 
     $doc->addScript('templates/sellacious/js/bootstrap/bootstrap.min.js');      // Bootstrap JS 
     $doc->addScript('templates/sellacious/js/notification/SmartNotification.min.js');   // Custom notification 
     $doc->addScript('templates/sellacious/js/plugin/cookie/jquery.cookie.min.js');    // cookie 
     $doc->addScript('templates/sellacious/js/sellacious-core.js');        // Sellacious core functions to work template wide 
     $doc->addScript('templates/sellacious/js/sellacious-notifier.js');       // Sellacious notification per view page 
     ?> 

     <script data-pace-options='{ "restartOnRequestAfter": true }' src="templates/sellacious/js/plugin/pace/pace.min.js"></script> 

     <jdoc:include type="head"/> 

     <!--[if IE 7]> 
     <h1>Your browser is out of date, please update your browser by going to www.microsoft.com/download</h1> 
     <![endif]--> 
    </head> 

    <?php $collapse = $app->input->cookie->get('collapsedmenu'); ?> 
    <body class="fixed-page-footer <?php echo $app->input->get('hidemainmenu') || $collapse ? 'minified' : '' ?>"><!-- 
    The possible classes: smart-style-3, minified, fixed-ribbon, fixed-header, fixed-width --> 

     <!-- HEADER --> 
     <header id="header" class="btn-group-justified"> 
      <div id="logo-group"> 
       <?php 
       $logo = 'templates/sellacious/images/logo.png'; 

       if (isset($helper) && $helper->access->isSubscribed()): 
        $altLogo = $helper->media->getImage('config.backoffice_logo', 1, false); 
        $logo = $altLogo ?: $logo; 
       endif; 
       ?> 
       <span id="logo"><a class="pull-left" href="<?php echo JRoute::_('index.php') ?>"> 
        <img src="<?php echo $logo ?>" alt="<?php echo htmlspecialchars($sitename) ?>"></a></span> 

       <?php if ($this->countModules('logo-group')) { ?> 
        <!-- OPTIMAL PLACE FOR NOTIFICATION MODULE --> 
        <jdoc:include type="modules" name="logo-group" style="none"/> 
       <?php } ?> 
      </div> 

      <?php if ($this->countModules('header-left')) { ?> 
       <!-- Project Context --> 
       <jdoc:include type="modules" name="header-left" style="none"/> 
      <?php } ?> 

      <!-- pulled right: nav area --> 
      <div class="pull-right" style="margin-right: 1px;"> 
       <!-- logout button --> 
       <div id="logout" class="btn-header transparent pull-right cursor-pointer"> 
        <?php $logout_url = 'index.php?option=com_login&task=logout&' . JSession::getFormToken() . '=1'; ?> 
        <span> <a href="<?php echo $logout_url ?>" title="Sign Out" data-action="userLogout" class="hasTooltip" data-placement="bottom" 
          data-logout-msg="You can improve your security further after logging out by closing this opened browser"><i 
           class="fa fa-sign-out"></i></a> </span> 
       </div> 
       <!-- end logout button --> 

       <!-- fullscreen button --> 
       <div id="fullscreen" class="btn-header transparent pull-right"> 
        <span> <a href="javascript:void(0);" data-action="launchFullscreen" class="hasTooltip" data-placement="bottom" 
           title="Full Screen"><i class="fa fa-arrows-alt"></i></a> </span> 
       </div> 
       <!-- end fullscreen button --> 

       <!-- back to Joomla administrator button --> 
       <div id="my-tore" class="btn-header transparent pull-right cursor-pointer"> 
        <span> <a href="../<?php echo basename(JPATH_ADMINISTRATOR); ?>/index.php" class="hasTooltip" data-placement="bottom" 
           title="Back to Joomla Administrator"><i class="fa fa-joomla"></i></a> </span> 
       </div> 
       <!-- end back to Joomla administrator button --> 

       <!-- Go to Joomla frontend button --> 
       <div id="joomla" class="btn-header transparent pull-right cursor-pointer"> 
        <span> <a href="../index.php" target="_blank" class="hasTooltip" data-placement="bottom" 
           title="View Site"><i class="fa fa-external-link"></i></a> </span> 
       </div> 
       <!-- end Go to Joomla frontend button --> 

       <!-- Go to Joomla frontend button --> 
       <div id="hide-menu" class="btn-header transparent pull-right cursor-pointer"> 
        <span> <a href="#" class="hasTooltip" data-placement="bottom" data-menu="hidemenu" 
           title="Menu"><i class="fa fa-reorder"></i></a> </span> 
       </div> 
       <!-- end Go to Joomla frontend button --> 

       <!-- Sync media button --> 
       <div id="sync-media" class="btn-header transparent pull-right cursor-pointer"> 
        <span> <a href="javascript:void(0)" class="hasTooltip" data-placement="bottom" data-action="sync-media" style="width: 135px;" 
           title="Refresh Media Uploads"><i class="fa fa-refresh"></i> <span class="text-normal"> <?php 
           echo JText::_('COM_SELLACIOUS_MEDIA_SYNC_BUTTON_LABEL') ?> </span></a> </span> 
       </div> 
       <!-- end Sync media button --> 

       <?php if ($this->countModules('header-right')): ?> 
        <jdoc:include type="modules" name="header-right" style="none"/> 
       <?php endif; ?> 
      </div> 
      <!-- end pulled right: nav area --> 

      <?php if (isset($helper) && ($helper->access->check('config.edit') || !$helper->access->isSubscribed())): ?> 
       <div id="context-news" class="pull-right padding-5"><!-- dynamic news --></div> 
      <?php endif; ?> 
     </header> 
     <!-- END HEADER --> 

     <!-- Left panel : Navigation area --> 
     <?php if ($this->countModules('left-panel') || $this->countModules('menu')) { ?> 
     <!-- Note: This width of the aside area can be adjusted through LESS variables --> 
     <aside id="left-panel"> 
      <div class="login-info"> 
       <span> <!-- User image size is adjusted inside CSS, it should stay as it --> 
        <a style="cursor:auto;" id="show-shortcut" data-action="toggleShortcut" href="index.php?option=com_sellacious&view=profile"> 
         <!--<img src="templates/sellacious/images/avatars/male.png" alt="me" class="online"/>--> 
         <i class="fa fa-user"></i> 
         <span><?php echo $user->get('name'); ?></span> 
        </a> 
       </span> 
      </div> 

      <!-- User info --> 
      <?php if ($this->countModules('left-panel')) { ?> 
       <jdoc:include type="modules" name="left-panel" style="none"/> 
      <?php } ?> 
      <!-- end user info --> 

      <!-- NAVIGATION : This navigation is also responsive 
      To make this navigation dynamic please make sure to link the node 
      (the reference to the nav > ul) after page load. Or the navigation will not initialize. 
      --> 

      <!-- User info --> 
      <?php if ($this->countModules('menu')) { ?> 
       <jdoc:include type="modules" name="menu" style="none"/> 
      <?php } ?> 
      <!-- end user info --> 

      <span class="minifyme"> <i class="fa fa-arrow-circle-left hit"></i> </span> 

     </aside> 
     <!-- END NAVIGATION --> 
     <?php } ?> 
     <!-- End Left panel : Navigation area --> 

     <!-- MAIN PANEL --> 
     <div id="main" role="main"> 

      <!-- RIBBON --> 
      <div id="ribbon"> 

       <!-- breadcrumb --> 
       <?php if ($this->countModules('ribbon-left')) { ?> 
        <jdoc:include type="modules" name="ribbon-left" style="none"/> 
       <?php } ?> 
       <!-- end breadcrumb --> 

       <?php if ($this->countModules('ribbon-right')) { ?> 
       <span class="ribbon-button-alignment pull-right"> 
        <jdoc:include type="modules" name="ribbon-right" style="none"/> 
       </span> 
       <?php } ?> 
       <div class="btn-headactions pull-right"> 
        <a href="http://sellacious.com/documentation.html" target="_blank" title="Document" class="primary"><i class="fa fa-book"></i> Documentation</a> 
        <a href="http://sellacious.com/community-support.html" target="_blank" title="Forum"><i class="fa fa-phone"></i> Support</a> 
        <a href="https://extensions.joomla.org/write-review/review/add?extension_id=11448" target="_blank" title="More info"><i class="fa fa-star"></i> Rate us on JED</a> 
       </div> 

      </div> 
      <!-- END RIBBON --> 

      <?php if ($this->countModules('toolbar') || $this->countModules('title')) : ?> 
       <div class="box-toolbar"> 
        <div class=""> 
         <!-- col --> 
         <div class="pull-left"> 
          <!-- PAGE HEADER --> 
          <jdoc:include type="modules" name="title"/> 
         </div> 
         <!-- end col --> 

         <!-- right side of the page with the sparkline graphs --> 
         <!-- col --> 
         <div class="pull-right"> 
          <?php if ($this->countModules('toolbar')) : ?> 
           <span class="pull-right"> 
            <jdoc:include type="modules" name="toolbar" style="none"/> 
           </span> 
          <?php endif; ?> 
         </div> 
         <!-- end col --> 
        </div> 
       </div> 
      <?php endif; ?> 

      <?php if ($this->countModules('top')) : ?> 
       <div class="row"> 
        <div class="col-sm-12"> 
         <jdoc:include type="modules" name="content-top" style="xhtml"/> 
        </div> 
       </div> 
      <?php endif; ?> 

      <?php if ($this->countModules('submenu')) : ?> 
       <div class="row"> 
        <div class="col-sm-12"> 
         <jdoc:include type="modules" name="submenu" style="none"/> 
        </div> 
       </div> 
      <?php endif; ?> 

      <div class="clearfix"></div> 

      <!-- MAIN CONTENT --> 
      <div id="content"> 

       <?php if ($this->countModules('content-top')) { ?> 
        <div class="row"> 
         <jdoc:include type="modules" name="content-top" style="none"/> 
        </div> 
       <?php } ?> 

       <div class="clearfix"></div> 

       <div class="component content-wrap"> 

        <div id="system-message-container"><jdoc:include type="message" style="xhtml"/></div> 
        <div class="clearfix"></div> 

        <jdoc:include type="component" style="xhtml"/> 
        <div class="clearfix"></div> 
       </div> 

       <?php if ($this->countModules('content-bottom')) { ?> 
        <div class="row"> 
         <jdoc:include type="modules" name="content-bottom" style="none"/> 
        </div> 
       <?php } ?> 

      </div> 

      <div class="clearfix"></div> 

      <!-- END MAIN CONTENT --> 

     </div> 
     <!-- END MAIN PANEL --> 

    <?php if ($this->countModules('footer')) { ?> 
     <jdoc:include type="modules" name="footer" style="none"/> 
    <?php } ?> 

     <jdoc:include type="modules" name="dynamic" style="xhtml"/> 

     <!-- Google Analytics code below --> 
     <?php if ($ga_code = $this->params->get('ga_code')) { ?> 
      <script type="text/javascript"> 
       var _gaq = _gaq || []; 
       _gaq.push(['_setAccount', '<?php echo htmlspecialchars($ga_code) ?>']); 
       _gaq.push(['_trackPageview']); 

       (function() { 
        var ga = document.createElement('script'); 
        ga.type = 'text/javascript'; 
        ga.async = true; 
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 
        var s = document.getElementsByTagName('script')[0]; 
        s.parentNode.insertBefore(ga, s); 
       })(); 
      </script> 
     <?php } ?> 

    </body> 

</html> 

입니다 나는이 링크

<a href="<?php echo JRoute::_('index.php?option=com_sellacious&view=store&id=' . $item->get('seller_uid')); ?>"> 
         <?php echo $item->get('seller_company', $item->get('seller_name')); ?></a> 

필요하지만 두 번째 파일에 구현하는 방법을 알고하지 않습니다.

답변

0

($sellers = **$this**->item->get('sellers'))의 평범한 제품보기에서보기 개체에 액세스해야합니다. 파일은 템플릿 파일이며 템플릿은 구성 요소보기 개체에 대한 액세스 권한이 없습니다. 템플릿이 렌더링 될 때 이미 가비지 수집 대상으로 표시되어 있습니다. 판매량이 많은 구성 요소가 포함 된 페이지에만 판매점 링크를 렌더링하는 경우 템플릿에 사용하기 위해 JRegistry에 데이터를 복사하여 저장할 수 있습니다. 템플릿에서 레이아웃을 재정의 할 때이 작업을 수행 할 수 있습니다 (레이아웃은 해당 구성 요소의 뷰 객체에 액세스 할 수 있습니다). 사용자 지정 구성 요소 나 다른 구성 요소에서 사용하기위한 것이라면 모델 논리를 작성하여 데이터베이스의 정보를 가져와야합니다. 이 경우, 나는 거만한 모델이 그것을하고 어떻게 필요한 부분 만 복사하는지 살펴볼 것입니다.

+0

답변 해 주셔서 감사합니다 (아직 upvote 수 없습니다)! joomla에서 링크를 렌더링하기 위해 백엔드 지식이 더 필요할 것입니다. D. –

+0

불행히도 귀하의 경우에는 사실이지만, 꽤 쉽습니다. Joomla 사이트에는 맞춤 구성 요소를 개발하는 방법에 관한 좋은 문서가 있습니다. 자습서를 통해 작업하면 뷰 객체가 어떻게 작동하는지 알 수 있습니다. JRegistry를 사용하여 애플리케이션의 다른 부분간에 데이터를 전달할 수 있습니다. 행운을 빕니다! –