Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 正在尝试与joomla中的用户id建立链接_Php_Joomla - Fatal编程技术网

Php 正在尝试与joomla中的用户id建立链接

Php 正在尝试与joomla中的用户id建立链接,php,joomla,Php,Joomla,我正试图在我的joomla组件中添加带有卖家商店链接的按钮,但我不知道如何才能做到这一点。 我正在添加php文件中的代码,该文件包含我需要的内容,但我不知道如何将其添加到另一个页面上。如果有人能指导我如何迈步,那就太棒了。 以下是包含商店链接的页面: <?php // no direct access defined('_JEXEC') or die; use Joomla\Registry\Registry; /** @var SellaciousViewProduct $this

我正试图在我的joomla组件中添加带有卖家商店链接的按钮,但我不知道如何才能做到这一点。
我正在添加php文件中的代码,该文件包含我需要的内容,但我不知道如何将其添加到另一个页面上。如果有人能指导我如何迈步,那就太棒了。
以下是包含商店链接的页面:

<?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>


您需要从文件中的Sellicity产品视图访问视图对象(即
$sellers=**$this**->item->get('sellers')
中的this)。您的文件是一个模板文件,模板无权访问组件视图对象-在模板呈现时,它已被标记为垃圾收集。如果只在包含Sellicity组件的页面上呈现Sellicity store链接,则可以复制数据并将其存储在JRegistry中,以便在模板中使用。您可以通过模板中的布局替代来完成此操作(布局可以访问其组件的视图对象)。如果要在自定义组件或其他组件中使用,则需要编写模型逻辑以从数据库中提取信息。在这种情况下,我将查看Sellicity模型是如何完成的,并只复制您需要的部分。

您需要从文件中的Sellicity产品视图访问视图对象(即
$sellers=**$this**->item->get('sellers')
)中的this)。您的文件是一个模板文件,模板无权访问组件视图对象-在模板呈现时,它已被标记为垃圾收集。如果只在包含Sellicity组件的页面上呈现Sellicity store链接,则可以复制数据并将其存储在JRegistry中,以便在模板中使用。您可以通过模板中的布局替代来完成此操作(布局可以访问其组件的视图对象)。如果要在自定义组件或其他组件中使用,则需要编写模型逻辑以从数据库中提取信息。在这种情况下,我会看看Sellicous车型是如何做到这一点的,然后只复制您需要的部分。

谢谢您的回答(我还不能升级)!我想我需要更多的后端知识来呈现joomla:D中的链接。不幸的是,在你的例子中是这样的,但这很容易。Joomla站点提供了关于如何开发自定义组件的好文档。如果阅读该教程,您将看到视图对象是如何工作的。您可以使用JRegistry在应用程序的不同部分之间传递数据。祝你好运谢谢你的回答(我还不能投票)!我想我需要更多的后端知识来呈现joomla:D中的链接。不幸的是,在你的例子中是这样的,但这很容易。Joomla站点提供了关于如何开发自定义组件的好文档。如果阅读该教程,您将看到视图对象是如何工作的。您可以使用JRegistry在应用程序的不同部分之间传递数据。祝你好运
<?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>