Сложности при адаптации шаблона Joomla с версии 1.5 под 2.5

12
S
На сайте с 03.07.2009
Offline
41
#11
shkiper:
А подробнее не скажите как именно...

Как правельно код построить в blog_item.php

---------- Добавлено 18.03.2013 в 15:27 ----------

Вот щас как я сделал но теперь кракозябры появляются upgrade.web-studio.biz.ua/jupgrade/novosti/

---------- Добавлено 18.03.2013 в 15:29 ----------

А если вставляю в item_blog.php этот код
function maxsite_str_word($text, $counttext = 10, $sep = ' ') { 
$words = split($sep, $text);
if ( count($words) > $counttext )
$text = join($sep, array_slice($words, 0, $counttext));
return $text;
}
, то не че не выводится

Подскажите плиз как же правельно всетаки сделать...


<?php
function maxsite_str_word($text, $counttext = 10, $sep = ' ') {
$words = split($sep, $text);
if ( count($words) > $counttext )
$text = join($sep, array_slice($words, 0, $counttext));
return $text;
}

$this->item->introtext=maxsite_str_word(strip_tags($this->item->introtext),10, ' ');
?>

Вот так надо использовать эту функцию. не забудьте что код php должен быть в тегах <?php ?>

Кодинг на PHP. Разработка расширений под Joomla.
S
На сайте с 27.01.2010
Offline
45
#12

Да только при вставке его выводится ошибка

Fatal error: Cannot redeclare maxsite_str_word() (previously declared in /home/stplast/web-studio.biz.ua/upgrade/jupgrade/templates/apogey25/html/com_content/category/blog_item.php:24) in /home/stplast/web-studio.biz.ua/upgrade/jupgrade/templates/apogey25/html/com_content/category/blog_item.php on line 29

---------- Добавлено 18.03.2013 в 16:37 ----------

Ругается на

}
29 строка
S
На сайте с 03.07.2009
Offline
41
#13
shkiper:
Да только при вставке его выводится ошибка

Fatal error: Cannot redeclare maxsite_str_word() (previously declared in /home/stplast/web-studio.biz.ua/upgrade/jupgrade/templates/apogey25/html/com_content/category/blog_item.php:24) in /home/stplast/web-studio.biz.ua/upgrade/jupgrade/templates/apogey25/html/com_content/category/blog_item.php on line 29

---------- Добавлено 18.03.2013 в 16:37 ----------

Ругается на
}
29 строка

нет у тебя функция maxsite_str_word объявлена два раза в 24 и 29 строка.

одну нужно убрать.

S
На сайте с 27.01.2010
Offline
45
#14
sdaprel:
нет у тебя функция maxsite_str_word объявлена два раза в 24 и 29 строка.
одну нужно убрать.

Я же скопировал тот код что вы дали

<?php 

function maxsite_str_word($text, $counttext = 10, $sep = ' ') {
$words = split($sep, $text);
if ( count($words) > $counttext )
$text = join($sep, array_slice($words, 0, $counttext));
return $text;
}

$this->item->introtext=maxsite_str_word(strip_tags($this->item->introtext),10, ' ');
?>
S
На сайте с 27.01.2010
Offline
45
#15

Что так и не подскажите, как правельно сделать?

S
На сайте с 03.07.2009
Offline
41
#16

функция maxsite_str_word объявлена два раза. Ищите где, и одно объявление удалите.

S
На сайте с 27.01.2010
Offline
45
#17

index.php шаблона

<?php

$js = "if(!window.jQuery)
document.write(unescape('<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js\">%3C/script%3E'));";
JFactory::getDocument()->addScriptDeclaration($js);
?>
<?php
$menu = & JSite::getMenu();
/**
* @package Joomla.Site
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

/* The following line loads the MooTools JavaScript Library */
JHtml::_('behavior.framework', true);

/* The following line gets the application object for things like displaying the site name */
$app = JFactory::getApplication();
?>
<?php echo '<?'; ?>xml version="1.0" encoding="<?php echo $this->_charset ?>"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<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>



<jdoc:include type="head" />


<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/ikSelect.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/template.css" type="text/css" />


<script src='<?php echo $this->baseurl ?>/templates/apogey25/js/calc.js'></script>
<script src='<?php echo $this->baseurl ?>/templates/apogey25/js/calc_config.js'></script>
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/apogey25/css/calc.css" />



<script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/apogey25/js/jquery.ikSelect.min.js"></script>
<script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/apogey25/js/main.js"></script>
</head>
<body>
<div id="header">
<div class="box">
<a href="/" id="logo"></a>
<jdoc:include type="modules" name="header" style="xhtml" />
</div>

</div>
<?php if($this->countModules('slide')){ ?>
<div id="slide">
<div class="box">
<jdoc:include type="modules" name="slide" style="xhtml" />
</div>






</div>
<?php } ?>

<div id="center">
<div class="box">
<jdoc:include type="modules" name="bread" style="xhtml" />
<div class="bg_box clr">
<?php if($this->countModules('left')){ $cont = ""; ?>
<div id="left">
<jdoc:include type="modules" name="left" style="xhtml2" />
</div>
<?php }else{ $cont = "no-left"; } ?>
<div id="content" class="<?php $cont ?>">

<jdoc:include type="modules" name="tcont" style="xhtml" />
<div class="cont_box">
<jdoc:include type="message" />
<jdoc:include type="component" />
</div>

<?php if(JRequest::getVar("view") == "article" && JRequest::getVar("option") == "com_content"){ ?>
<jdoc:include type="modules" name="bcont2" style="xhtml4" />
<?php } ?>
<jdoc:include type="modules" name="bcont" style="xhtml4" />


</div>

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

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

</div>
<div id="footer">


<div class="box">
<jdoc:include type="modules" name="footer" style="xhtml" />

</div>


</div>

</body>
</html>

/html/com_content/category/

blog.php

<?php

/**
* @package Joomla.Site
* @subpackage Templates.beez5
* @copyright Copyright (C) 2005 - 2009 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// no direct access
defined('_JEXEC') or die;
$app = JFactory::getApplication();
$templateparams =$app->getTemplate(true)->params;

if ($templateparams->get('html5')!=1)
{
require JPATH_BASE.'/components/com_content/views/category/tmpl/blog.php';
//evtl. ersetzen durch JPATH_COMPONENT.'/views/...'
} else {
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
$cparams = JComponentHelper::getParams('com_media');

// If the page class is defined, add to class as suffix.
// It will be a separate class if the user starts it with a space
?>
<section class="blog<?php echo $this->pageclass_sfx;?>">
<?php if ($this->params->get('show_page_heading')!=0 or $this->params->get('show_category_title')): ?>
<h1>
<?php echo $this->escape($this->params->get('page_heading')); ?>
<?php if ($this->params->get('show_category_title'))
{

echo '<span class="subheading-category">'.$this->category->title.'</span>';
}
?>
</h1>
<?php endif; ?>

<?php if ($this->params->get('show_description', 1) || $this->params->def('show_description_image', 1)) : ?>
<div class="category-desc">
<?php if ($this->params->get('show_description_image') && $this->category->getParams()->get('image')) : ?>
<img src="<?php echo $this->category->getParams()->get('image'); ?>"/>
<?php endif; ?>
<?php if ($this->params->get('show_description') && $this->category->description) : ?>
<?php echo JHtml::_('content.prepare', $this->category->description, '', 'com_content.category'); ?>
<?php endif; ?>
<div class="clr"></div>
</div>
<?php endif; ?>



<?php $leadingcount=0 ; ?>
<?php if (!empty($this->lead_items)) : ?>
<div class="items-leading">
<?php foreach ($this->lead_items as &$item) : ?>
<article class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? 'system-unpublished' : null; ?>">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>
</article>
<?php
$leadingcount++;
?>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php
$introcount=(count($this->intro_items));
$counter=0;
?>
<?php if (!empty($this->intro_items)) : ?>

<?php foreach ($this->intro_items as $key => &$item) : ?>
<?php
$key= ($key-$leadingcount)+1;
$rowcount=( ((int)$key-1) % (int) $this->columns) +1;
$row = $counter / $this->columns ;

if ($rowcount==1) : ?>
<div class="items-row cols-<?php echo (int) $this->columns;?> <?php echo 'row-'.$row ; ?>">
<?php endif; ?>
<article class="item column-<?php echo $rowcount;?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>
</article>
<?php $counter++; ?>
<?php if (($rowcount == $this->columns) or ($counter ==$introcount)): ?>
<span class="row-separator"></span>
</div>

<?php endif; ?>
<?php endforeach; ?>


<?php endif; ?>

<?php if (!empty($this->link_items)) : ?>

<?php echo $this->loadTemplate('links'); ?>

<?php endif; ?>


<?php if (is_array($this->children[$this->category->id]) && count($this->children[$this->category->id]) > 0 && $this->params->get('maxLevel') !=0) : ?>
<div class="cat-children">
<h3>
<?php echo JTEXT::_('JGLOBAL_SUBCATEGORIES'); ?>
</h3>
<?php echo $this->loadTemplate('children'); ?>
</div>
<?php endif; ?>

<?php if (($this->params->def('show_pagination', 1) == 1 || ($this->params->get('show_pagination') == 2)) && ($this->pagination->get('pages.total') > 1)) : ?>
<div class="pagination">
<?php if ($this->params->def('show_pagination_results', 1)) : ?>
<p class="counter">
<?php echo $this->pagination->getPagesCounter(); ?>
</p>

<?php endif; ?>
<?php echo $this->pagination->getPagesLinks(); ?>
</div>
<?php endif; ?>

</section>

<?php } ?>

blog_item.php

<?php defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');

?>

<div class="article-item">




<h2> <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>">
<?php echo $this->escape($this->item->title); ?></a>
</h2>
<?

$date= explode(" ",$this->item->created);
$date= explode("-",$date[0]);
$date= $date[2].".".$date[1].".".$date[0];

echo $date; ?>
<div class="img_box">

<?php echo substr($this->item->introtext, 0, 580).'...';?>




<?php // to do not that elegant would be nice to group the params ?>

</div>

<div class="item-separator"></div>

S
На сайте с 27.01.2010
Offline
45
#18

defaul.php

<?php

/**
* @package Joomla.Site
* @subpackage Templates.beez5
* @copyright Copyright (C) 2005 - 2009 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// no direct access
defined('_JEXEC') or die;
$app = JFactory::getApplication();
$templateparams =$app->getTemplate(true)->params;

if (!$templateparams->get('html5', 0))
{
require JPATH_BASE.'/components/com_content/views/category/tmpl/default.php';
//evtl. ersetzen durch JPATH_COMPONENT.'/views/...'
} else {
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');

$pageClass = $this->params->get('pageclass_sfx');
?>
<section class="category-list<?php echo $this->pageclass_sfx;?>">
<?php if ($this->params->get('show_page_heading', 1)) : ?>
<?php if ($this->params->get('show_page_heading', 1) and ($this->params->get('show_category_title') or $this->params->get('page_subheading'))) : ?>
<hgroup>
<?php endif; ?>
<h1>
<?php echo $this->escape($this->params->get('page_heading')); ?>
</h1>
<?php endif; ?>

<?php if ($this->params->get('show_category_title') or $this->params->get('page_subheading')) : ?>
<h2>
<?php echo $this->escape($this->params->get('page_subheading')); ?>
<?php if ($this->params->get('show_category_title'))
{

echo '<span class="subheading-category">'.$this->category->title.'</span>';
}
?>
</h2>
<?php if ($this->params->get('show_page_heading', 1) and ($this->params->get('show_category_title', 1) or $this->params->get('page_subheading'))) : ?>
</hgroup>
<?php endif; ?>
<?php endif; ?>

<?php if ($this->params->get('show_description', 1) || $this->params->def('show_description_image', 1)) : ?>
<div class="category-desc">
<?php if ($this->params->get('show_description_image') && $this->category->getParams()->get('image')) : ?>
<img src="<?php echo $this->category->getParams()->get('image'); ?>"/>
<?php endif; ?>
<?php if ($this->params->get('show_description') && $this->category->description) : ?>
<?php echo JHtml::_('content.prepare', $this->category->description, '', 'com_content.category'); ?>
<?php endif; ?>
<div class="clr"></div>
</div>
<?php endif; ?>


<?php if (is_array($this->children[$this->category->id]) && count($this->children[$this->category->id]) > 0 && $this->params->get('maxLevel') !=0) : ?>
<div class="cat-children">

<?php if ($this->params->get('show_category_title') or $this->params->get('page_subheading'))
{ echo '<h3>' ;}
else

{echo '<h2>' ;} ?>

<?php echo JTEXT::_('JGLOBAL_SUBCATEGORIES'); ?>
<?php if ($this->params->get('show_category_title') or $this->params->get('page_subheading'))
{ echo '</h3>' ;}
else

{echo '</h2>' ;} ?>
<?php echo $this->loadTemplate('children'); ?>
</div>
<?php endif; ?>

<div class="cat-items">
<?php echo $this->loadTemplate('articles'); ?>
</div>

</section>
<?php } ?>

default_article.php

<?php

/**
* @package Joomla.Site
* @subpackage Templates.beez5
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

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

$app = JFactory::getApplication();
$templateparams =$app->getTemplate(true)->params;

if ($templateparams->get('html5') != 1) :
require JPATH_BASE.'/components/com_content/views/category/tmpl/default_articles.php';
//evtl. ersetzen durch JPATH_COMPONENT.'/views/...'
return;
endif;

JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::core();

$n = count($this->items);
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
?>

<?php if (empty($this->items)) : ?>

<?php if ($this->params->get('show_no_articles', 1)) : ?>
<p><?php echo JText::_('COM_CONTENT_NO_ARTICLES'); ?></p>
<?php endif; ?>

<?php else : ?>

<form action="<?php echo htmlspecialchars(JFactory::getURI()->toString()); ?>" method="post" name="adminForm" id="adminForm">
<?php if ($this->params->get('filter_field') != 'hide') : ?>
<fieldset class="filters">
<legend class="element-invisible">
<?php echo JText::_('JGLOBAL_FILTER_LABEL'); ?>
</legend>

<div class="filter-search">
<label class="filter-search-lbl" for="filter-search"><?php echo JText::_('COM_CONTENT_'.$this->params->get('filter_field').'_FILTER_LABEL').'***160;'; ?></label>
<input type="text" name="filter-search" id="filter-search" value="<?php echo $this->escape($this->state->get('list.filter')); ?>" class="inputbox" onchange="document.adminForm.submit();" title="<?php echo JText::_('COM_CONTENT_FILTER_SEARCH_DESC'); ?>" />
</div>
<?php endif; ?>

<?php if ($this->params->get('show_pagination_limit')) : ?>
<div class="display-limit">
<?php echo JText::_('JGLOBAL_DISPLAY_NUM'); ?>***160;
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<?php endif; ?>

<?php if ($this->params->get('filter_field') != 'hide') :?>
</fieldset>
<?php endif; ?>

<table class="category">
<?php if ($this->params->get('show_headings')) :?>
<thead>
<tr>

<th class="list-title" id="tableOrdering">
<?php echo JHtml::_('grid.sort', 'COM_CONTENT_HEADING_TITLE', 'a.title', $listDirn, $listOrder) ; ?>
</th>

<?php if ($date = $this->params->get('list_show_date')) : ?>
<th class="list-date" id="tableOrdering2">
<?php if ($date == "created") : ?>
<?php echo JHtml::_('grid.sort', 'COM_CONTENT_'.$date.'_DATE', 'a.created', $listDirn, $listOrder); ?>
<?php elseif ($date == "modified") : ?>
<?php echo JHtml::_('grid.sort', 'COM_CONTENT_'.$date.'_DATE', 'a.modified', $listDirn, $listOrder); ?>
<?php elseif ($date == "published") : ?>
<?php echo JHtml::_('grid.sort', 'COM_CONTENT_'.$date.'_DATE', 'a.publish_up', $listDirn, $listOrder); ?>
<?php endif; ?>
</th>
<?php endif; ?>

<?php if ($this->params->get('list_show_author', 1)) : ?>
<th class="list-author" id="tableOrdering3">
<?php echo JHtml::_('grid.sort', 'JAUTHOR', 'author', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>

<?php if ($this->params->get('list_show_hits', 1)) : ?>
<th class="list-hits" id="tableOrdering4">
<?php echo JHtml::_('grid.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
</tr>
</thead>
<?php endif; ?>

<tbody>

<?php foreach ($this->items as $i => &$article) : ?>
<tr class="cat-list-row<?php echo $i % 2; ?>">

<?php if (in_array($article->access, $this->user->getAuthorisedViewLevels())) : ?>

<td class="list-title">
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid)); ?>">
<?php echo $this->escape($article->title); ?></a>
</td>

<?php if ($this->params->get('list_show_date')) : ?>
<td class="list-date">
<?php echo JHtml::_('date', $article->displayDate, $this->escape(
$this->params->get('date_format', JText::_('DATE_FORMAT_LC3')))); ?>
</td>
<?php endif; ?>

<<?php if ($this->params->get('list_show_author', 1)) : ?>
<td class="list-author">
<?php if(!empty($article->author) || !empty($article->created_by_alias)) : ?>
<?php $author = $article->author ?>
<?php $author = ($article->created_by_alias ? $article->created_by_alias : $author);?>

<?php if (!empty($article->contactid ) && $this->params->get('link_author') == true):?>
<?php echo JHtml::_(
'link',
JRoute::_('index.php?option=com_contact&view=contact&id='.$article->contactid),
$author
); ?>

<?php else :?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', $author); ?>
<?php endif; ?>
<?php endif; ?>
</td>
<?php endif; ?>

<?php if ($this->params->get('list_show_hits', 1)) : ?>
<td class="list-hits">
<?php echo $article->hits; ?>
</td>
<?php endif; ?>

<?php else : ?>
<td>
<?php
echo $this->escape($article->title).' : ';
$menu = JFactory::getApplication()->getMenu();
$active = $menu->getActive();
$itemId = $active->id;
$link = JRoute::_('index.php?option=com_users&view=login&Itemid='.$itemId);
$returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug));
$fullURL = new JURI($link);
$fullURL->setVar('return', base64_encode($returnURL));
?>
<a href="<?php echo $fullURL; ?>" class="register">
<?php echo JText::_( 'COM_CONTENT_REGISTER_TO_READ_MORE' ); ?></a>
</td>
<?php endif; ?>

</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>

<?php // Code to add a link to submit an article. ?>
<?php if ($this->category->getParams()->get('access-create')) : ?>
<?php echo JHtml::_('icon.create', $this->category, $this->category->params); ?>
<?php endif; ?>

<?php // Add pagination links ?>
<?php if (!empty($this->items)) : ?>
<?php if (($this->params->def('show_pagination', 2) == 1 || ($this->params->get('show_pagination') == 2)) && ($this->pagination->get('pages.total') > 1)) : ?>
<div class="pagination">

<?php if ($this->params->def('show_pagination_results', 1)) : ?>
<p class="counter">
<?php echo $this->pagination->getPagesCounter(); ?>
</p>
<?php endif; ?>

<?php echo $this->pagination->getPagesLinks(); ?>
</div>
<?php endif; ?>

<div>
<!-- @TODO add hidden inputs -->
<input type="hidden" name="filter_order" value="" />
<input type="hidden" name="filter_order_Dir" value="" />
<input type="hidden" name="limitstart" value="" />
</div>
</form>
<?php endif; ?>
S
На сайте с 03.07.2009
Offline
41
#19

blog_item.php

<?php defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');

?>

<div class="article-item">




<h2> <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>">
<?php echo $this->escape($this->item->title); ?></a>
</h2>
<?php

$date= explode(" ",$this->item->created);
$date= explode("-",$date[0]);
$date= $date[2].".".$date[1].".".$date[0];

echo $date; ?>
<div class="img_box">


<?php

if (!function_exists('strEx')) {
function strEx($str, $length){
$str = explode(" ", $str);
$nstr = array();
for($t=0;$t<count($str);$t++){
$strl = strlen(implode($nstr));
$strr = strlen(implode($nstr)." ".$str[$t]);
if($strl<$length && $strr<$length){
array_push($nstr, " ".$str[$t]);
}else{
return trim(implode($nstr));
}
}
}
}
echo strEx($this->item->introtext, 580); ?>



<?php // to do not that elegant would be nice to group the params ?>

</div>

<div class="item-separator"></div>



---------- Добавлено 21.03.2013 в 14:18 ----------

Что бы код нормально перенести без звездочек, квотни мой пост, и там смотри правильный код.
S
На сайте с 27.01.2010
Offline
45
#20

Спасибо большое,очень выручили...

12

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий