Новости Joomla

0 Пользователей и 1 Гость просматривают эту тему.
  • 11 Ответов
  • 2578 Просмотров
*

salem.sakarov

  • Осваиваюсь на форуме
  • 29
  • 0 / 0
Доброе утро всем!

На сайте при детальном просмотре материала выводятся рейтинг и оценка материала, материал, кнопки соцсетей и комментарии дискас.

Нужно переместить рейтинг  и оценку под материал, но выше дискас комментов.

в файле /plugins/content/vote.php заменил onContentBeforeDisplay на onContentAfterDisplay,  - рейтинг выводится самым последним на странице,

после этого поменял в /plugins/content/jw_disqus onContentPrepare на onContentAfterDisplay, - все равно рейтинг выводится после комментов т.е. самым последним.

Нужна ваша помощь,  как установить порядок вывода onContentAfterDisplay? Или как по другому решить эту задачу?
*

b2z

  • Глобальный модератор
  • 7290
  • 778 / 0
  • Разраблю понемногу
*

salem.sakarov

  • Осваиваюсь на форуме
  • 29
  • 0 / 0
В менеджере плагинов порядок поменял, все осталось также - под материалом сначала идут комментарии дискас, а после них рейтинг и оценка.
*

b2z

  • Глобальный модератор
  • 7290
  • 778 / 0
  • Разраблю понемногу
*

SmokerMan

  • Гуру
  • 5293
  • 720 / 26
после этого поменял в /plugins/content/jw_disqus onContentPrepare на onContentAfterDisplay, - все равно рейтинг выводится после комментов т.е. самым последним.
смысл этого действия?
Это 2 разных события.
в onContentPrepare как правило меняется содержимое или идет подстановка в сам текст, т.е. в нем ничего не возвращается.
а в onContentAfterDisplay или onContentBeforeDisplay как раз возвращается значение, которое нужно подставить
*

salem.sakarov

  • Осваиваюсь на форуме
  • 29
  • 0 / 0
смысл этого действия?
Это 2 разных события.
в onContentPrepare как правило меняется содержимое или идет подстановка в сам текст, т.е. в нем ничего не возвращается.
а в onContentAfterDisplay или onContentBeforeDisplay как раз возвращается значение, которое нужно подставить

сделал с мыслью о том что onContentBeforeDisplay срабатывает после вывода материала, и сумев задать порядок вывода рейтинга и дискаса, получу то что нужно  - 1.материал 2. рейтинг 3. дискас

Спасибо за разьяснение событий. И все же, как правильнее поступить в моем случае?
*

SmokerMan

  • Гуру
  • 5293
  • 720 / 26
Спасибо за разьяснение событий. И все же, как правильнее поступить в моем случае?
как правильно сказать не могу, потому что надо видеть код плагина.
Но суть "грубо" говоря я могу расписать.

Событие onContentPrepare делает вот что
Код
$row->text .= 'Чего-то там 1';
return;

Событие onContentAfterDisplay делает вот что
Код
return 'Чего-то там 2';

и дальше в выводе получается
Код
echo $row->text; // тут выведиться что добавилось в событии onContentPrepare 

echo $event->afterDisplay; // а тут уже будет выводиться все события onContentAfterDisplay

Т.е. порядок тут ничего не изменит.
Если меняется событие onContentPrepare на onContentAfterDisplay, то нужно поменять в плагине
Код
$row->text .= 'Чего-то там 1';
return;

на
Код
return 'Чего-то там 1';

*

Yamamura

  • Захожу иногда
  • 99
  • 3 / 0
как правильно сказать не могу, потому что надо видеть код плагина.
Добрый день. Столкнулся с такой же проблемой — комментарии Дискаса выводятся сразу после текста и их нельзя никуда передвинуть, в результате те же теги, навигация (следующая / предыдущая новость) и тд выводятся под комментариями, что вообще неудобно. Не могли бы вы конкретно сказать, как подправить код, чтобы комментарии Дискаса можно было переместить в самый низ страницы? Вот код плагина Дискаса:

Код: php
<?php
/**
 * @version 3.5
 * @package DISQUS Comments for Joomla! (package)
 * @author JoomlaWorks - http://www.joomlaworks.net
 * @copyright Copyright (c) 2006 - 2014 JoomlaWorks Ltd. All rights reserved.
 * @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 */

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

jimport('joomla.plugin.plugin');
if (version_compare(JVERSION, '1.6.0', 'ge'))
{
jimport('joomla.html.parameter');
}

class plgContentJw_disqus extends JPlugin
{

// JoomlaWorks reference parameters
var $plg_name = "jw_disqus";
var $plg_copyrights_start = "\n\n<!-- JoomlaWorks \"DISQUS Comments for Joomla!\" (v3.5) starts here -->\n";
var $plg_copyrights_end = "\n\n<!-- JoomlaWorks \"DISQUS Comments for Joomla!\" (v3.5) ends here -->\n";

function plgContentJw_disqus(&$subject, $params)
{
parent::__construct($subject, $params);

// Define the DS constant under Joomla! 3.0
if (!defined('DS'))
{
define('DS', DIRECTORY_SEPARATOR);
}
}

// Joomla! 1.5
function onPrepareContent(&$row, &$params, $page = 0)
{
$this->renderDisqus($row, $params, $page = 0);
}

// Joomla! 1.6+
function onContentPrepare($context, &$row, &$params, $page = 0)
{
$this->renderDisqus($row, $params, $page = 0);
}

// The main function
function renderDisqus(&$row, &$params, $page)
{

// API
$mainframe = JFactory::getApplication();
$document = JFactory::getDocument();
$user = JFactory::getUser();

// Assign paths
$sitePath = JPATH_SITE;
$siteUrl = JURI::root(true);

// Requests
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$layout = JRequest::getCmd('layout');
$page = JRequest::getCmd('page');
$secid = JRequest::getInt('secid');
$catid = JRequest::getInt('catid');
$itemid = JRequest::getInt('Itemid');
if (!$itemid)
$itemid = 999999;

// Check if plugin is enabled
if (JPluginHelper::isEnabled('content', $this->plg_name) == false)
return;

// Load the plugin language file the proper way
JPlugin::loadLanguage('plg_content_'.$this->plg_name, JPATH_ADMINISTRATOR);

// Simple checks before parsing the plugin
$properties = get_object_vars($row);
if (!array_key_exists('catid', $properties))
return;
if (version_compare(JVERSION, '1.6.0', 'lt'))
{
if (!array_key_exists('sectionid', $properties))
return;
}
if (!$row->id || $option == 'com_rokdownloads')
return;

// ----------------------------------- Get plugin parameters -----------------------------------
$plugin = JPluginHelper::getPlugin('content', $this->plg_name);
$pluginParams = version_compare(JVERSION, '1.6.0', 'lt')? new JParameter($plugin->params) : new JRegistry($plugin->params);

$disqusSubDomain = trim($pluginParams->get('disqusSubDomain', ''));
$disqusLanguage = $pluginParams->get('disqusLanguage');
$selectedCategories = $pluginParams->get('selectedCategories', '');
$selectedMenus = $pluginParams->get('selectedMenus', '');
$disqusListingCounter = $pluginParams->get('disqusListingCounter', 1);
$disqusArticleCounter = $pluginParams->get('disqusArticleCounter', 1);
$disqusDevMode = $pluginParams->get('disqusDevMode', 0);

// External parameter for controlling plugin layout within modules
if (!$params)
$params = version_compare(JVERSION, '1.6.0', 'lt')? new JParameter(null) : new JRegistry(null);
$parsedInModule = $params->get('parsedInModule');

if (!$disqusSubDomain)
{
// Quick check before we proceed
// Fix: Add notice only one time in page...
if (!isset($this->noticeRaised))
{
$this->noticeRaised = true;
JError::raiseNotice('', JText::_('JW_DISQUS_PLEASE_ENTER_YOUR_DISQUS_SUBDOMAIN'));
}
return;
}
else
{
// Perform some parameter cleanups
$disqusSubDomain = str_replace(array(
'http://',
'.disqus.com/',
'.disqus.com'
), array(
'',
'',
''
), $disqusSubDomain);
}

// ----------------------------------- Before plugin render -----------------------------------

// Get the current category
$currectCategory = $row->catid;

// Define plugin category restrictions
$selectedCategories = (array)$selectedCategories;
if (sizeof($selectedCategories) == 1 && $selectedCategories[0] == '')
{
$categories[] = $currectCategory;
}
else
{
$categories = $selectedCategories;
}

// Define plugin menu restrictions
$selectedMenus = (array)$selectedMenus;
if (sizeof($selectedMenus) == 1 && $selectedMenus[0] == '')
{
$menus[] = $itemid;
}
else
{
$menus = $selectedMenus;
}

// ----------------------------------- Prepare elements -----------------------------------

// Includes
require_once (dirname(__FILE__).DS.$this->plg_name.DS.'includes'.DS.'helper.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');

// Output object
$output = new stdClass;

// Article URLs
$websiteURL = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off")? "https://".$_SERVER['HTTP_HOST'] : "http://".$_SERVER['HTTP_HOST'];

if (version_compare(JVERSION, '1.6.0', 'ge'))
{
$levels = $user->getAuthorisedViewLevels();
if (in_array($row->access, $levels))
{
if ($view == 'article')
{
$itemURL = $row->readmore_link;
}
else
{
$itemURL = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid));
}
}
}
else
{
$itemURL = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
}

$itemURLbrowser = explode("#", $websiteURL.$_SERVER['REQUEST_URI']);
$itemURLbrowser = $itemURLbrowser[0];

// Article URL assignments
$output->itemURL = $websiteURL.$itemURL;
$output->itemURLrelative = $itemURL;
$output->itemURLbrowser = $itemURLbrowser;
$output->disqusIdentifier = substr(md5($disqusSubDomain), 0, 10).'_id'.$row->id;

// Fetch elements specific to the "article" view only
if (in_array($currectCategory, $categories) && in_array($itemid, $menus) && $option == 'com_content' && $view == 'article')
{
$output->comments = "
<div id=\"disqus_thread\"></div>
<script type=\"text/javascript\">
//<![CDATA[
var disqus_shortname = '".$disqusSubDomain."';
var disqus_url = '".$output->itemURL."';
var disqus_identifier = '".substr(md5($disqusSubDomain), 0, 10)."_id".$row->id."';
var disqus_developer = '".$disqusDevMode."';
var disqus_config = function(){
this.language = '{$disqusLanguage}';
};
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
//]]>
</script>
<noscript>
<a href=\"http://".$disqusSubDomain.".disqus.com/?url=ref\">".JText::_("JW_DISQUS_VIEW_THE_DISCUSSION_THREAD")."</a>
</noscript>
";
}

// ----------------------------------- Render the output -----------------------------------
if (in_array($currectCategory, $categories) && in_array($itemid, $menus))
{

if (!defined('JW_DISQUS'))
define('JW_DISQUS', true);

// Append head includes only when the document is in HTML mode
if (JRequest::getCmd('format') == 'html' || JRequest::getCmd('format') == '')
{

// CSS
$plgCSS = DisqusHelper::getTemplatePath($this->plg_name, 'css/template.css');
$plgCSS = $plgCSS->http;

$document->addStyleSheet($plgCSS);

// JS
if (version_compare(JVERSION, '1.6.0', 'ge'))
{
JHtml::_('behavior.framework');
}
else
{
JHTML::_('behavior.mootools');
}
}

if (($option == 'com_content' && $view == 'article') && $parsedInModule != 1)
{

// Fetch the template
ob_start();
$dsqArticlePath = DisqusHelper::getTemplatePath($this->plg_name, 'article.php');
$dsqArticlePath = $dsqArticlePath->file;
include ($dsqArticlePath);
$getArticleTemplate = $this->plg_copyrights_start.ob_get_contents().$this->plg_copyrights_end;
ob_end_clean();

// Output
$row->text = $getArticleTemplate;

}
else if ($disqusListingCounter && (($option == 'com_content' && ($view == 'frontpage' || $view == "featured" || $view == 'section' || $view == 'category')) || $parsedInModule == 1))
{

// Set '$row->text' to '$row->introtext' for J!1.6+
if (version_compare(JVERSION, '1.6.0', 'ge'))
$row->text = $row->introtext;

// Fetch the template
ob_start();
$dsqListingPath = DisqusHelper::getTemplatePath($this->plg_name, 'listing.php');
$dsqListingPath = $dsqListingPath->file;
include ($dsqListingPath);
$getListingTemplate = $this->plg_copyrights_start.ob_get_contents().$this->plg_copyrights_end;
ob_end_clean();

// Output
$row->text = $getListingTemplate;

}

} // END IF

} // END FUNCTION

} // END CLASS

А это файл article.php Дискаса, который всё выводит:
Код: php
<?php
/**
 * @version 3.5
 * @package DISQUS Comments for Joomla! (package)
 * @author JoomlaWorks - http://www.joomlaworks.net
 * @copyright Copyright (c) 2006 - 2014 JoomlaWorks Ltd. All rights reserved.
 * @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 */

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

?>

<a id="startOfPage"></a>

<?php if($disqusArticleCounter): ?>
<!-- DISQUS comments counter and anchor link -->
<div class="jwDisqusArticleCounter">
<span>
<a class="jwDisqusArticleCounterLink" href="#disqus_thread" data-disqus-identifier="<?php echo $output->disqusIdentifier; ?>"><?php echo JText::_("JW_DISQUS_VIEW_COMMENTS"); ?></a>
</span>
<div class="clr"></div>
</div>
<?php endif; ?>

<?php echo $row->text; ?>

<!-- DISQUS comments block -->
<div class="jwDisqusForm">
<?php echo $output->comments; ?>
<div id="jwDisqusFormFooter">
<a target="_blank" href="http://disqus.com" class="dsq-brlink">
<?php echo JText::_("JW_DISQUS_BLOG_COMMENTS_POWERED_BY"); ?> <span class="logo-disqus">DISQUS</span>
</a>
<a id="jwDisqusBackToTop" href="#startOfPage">
<?php echo JText::_("JW_DISQUS_BACK_TO_TOP"); ?>
</a>
<div class="clr"></div>
</div>
</div>

<div class="clr"></div>
*

b2z

  • Глобальный модератор
  • 7290
  • 778 / 0
  • Разраблю понемногу
Цитировать
после этого поменял в /plugins/content/jw_disqus onContentPrepare на onContentAfterDisplay
*

Yamamura

  • Захожу иногда
  • 99
  • 3 / 0
после этого поменял в /plugins/content/jw_disqus onContentPrepare на onContentAfterDisplay
Это мне ответ? Это ничего не даст — выше по теме написано, почему.
*

b2z

  • Глобальный модератор
  • 7290
  • 778 / 0
  • Разраблю понемногу
Это мне ответ? Это ничего не даст — выше по теме написано, почему.
Должно дать. Порядок вывода определяется порядком менеджера плагинов. Вы пробовали менять?
*

Yamamura

  • Захожу иногда
  • 99
  • 3 / 0
Должно дать. Порядок вывода определяется порядком менеджера плагинов. Вы пробовали менять?
Что это должно дать, если ТС написал, что это не помогло, и SmokerMan ответил, почему не помогло.
Меня интересует, что именно и как нужно заменить в приведённом мною коде плагина, чтобы Дискас не встраивался в содержимое статьи, а выводился отдельно ниже, наравне с другими плагинами, дабы можно было изменить порядок и переместить Дискас в самый низ.
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

Собственный макет вывода материалов для категории

Автор kolhoz

Ответов: 1
Просмотров: 377
Последний ответ 02.11.2021, 04:13:51
от draff
Вопрос по роутеру: вложенность статей друг в друга

Автор effrit

Ответов: 6
Просмотров: 508
Последний ответ 30.09.2021, 10:17:15
от sivers
Не работает порядок категорий

Автор Nikias

Ответов: 9
Просмотров: 708
Последний ответ 02.08.2021, 19:05:28
от Nikias
Как фильтровать список вывода материалов по принадлежности к категории?

Автор Damarkuzz

Ответов: 0
Просмотров: 349
Последний ответ 23.07.2021, 19:56:10
от Damarkuzz
Модуль вывода категорий с функцией ajax

Автор Damarkuzz

Ответов: 3
Просмотров: 511
Последний ответ 26.06.2021, 10:41:31
от Damarkuzz