Сайт сообщества | Клуб пользователей | О проекте

Имя
Пароль
ПравилаРегистрацияСправка
Сообщения за деньПоиск

Вернуться   Клуб пользователей портальной системы RUNCMS > Опен Ресурс > Разработчикам > Готовые хаки

Ответ
 
Опции темы Опции просмотра
Lover_N001 вне форума Lover_N001
Участник


| Цитировать Старый #1 12-20-2012, 15:18

Увидел у уважаемого юзера Usama новую версию модуля новостей, и там понравилась функция вывода тэгов. Решил на одном из своих сайтов (роня 1.6.2.) прикрутить этот хак, думаю на 1.7 тоже заработает.

Для начала идем в пхпадмин, открываем базу и в таблице stories добавляем в конце
tegi varchar(255) NOT NULL default '' (можно поставить и mediumtext)

Будут изменены следующие файлы:
/class/xoopsstory.php
/modules/news/admin/index.php
/modules/news/admin/storyform.inc.php
/modules/news/class/class.newsstory.php
/modules/news/article.php

добавленные файлы скачать: TEGS

1) открываем /class/xoopsstory.php и в class XoopsStory после
PHP код:
var $table
вставляем
PHP код:
var $tegi
находим функцию
PHP код:
function setStoryId($value) { 
и перед ним добавляем
PHP код:
function settegi($value) {
$this->tegi $value;

находим функцию
PHP код:
function store($approved=false) { 
и полностью ее заменяем
PHP код:
function store($approved=false) {
global 
$myts$db;
//$this->approved = $approved;
$title    $myts->makeTboxData4Save($this->title);
$hometext $myts->makeTboxData4Save($this->hometext);
$bodytext $myts->makeTboxData4Save($this->bodytext);
$tegi =$this->tegi;
if (!isset(
$this->notifypub) || $this->notifypub != 1) {
$this->notifypub 0;
}
if ( !isset(
$this->topicdisplay) || $this->topicdisplay != ) {
$this->topicdisplay 1;
}
if (!isset(
$this->storyid)) {
$newstoryid $db->genId($this->table."_storyid_seq");
$created time();
if (
$this->approved) {
$sql "
INSERT INTO "
.$this->table." SET
storyid=
$newstoryid,
uid="
.$this->uid.",
title='"
.$title."',
created="
.$created.",
published="
.$this->published.",
hostname='"
.$this->hostname."',
allow_html="
.intval($this->allow_html).",
allow_smileys="
.intval($this->allow_smileys).",
allow_bbcode="
.intval($this->allow_bbcode).",
hometext='"
.$hometext."',
bodytext='"
.$bodytext."',
counter=0,
topicid="
.intval($this->topicid).",
ihome="
.intval($this->ihome).",
notifypub="
.intval($this->notifypub).",
type='"
.$this->type."',
topicdisplay=
$this->topicdisplay,
topicalign='"
.$this->topicalign."',
tegi='"
.$tegi."'";
} else {
$sql "
INSERT INTO "
.$this->table." SET
storyid=
$newstoryid,
uid="
.$this->uid.",
title='"
.$title."',
created="
.$created.",
published=0,
hostname='"
.$this->hostname."',
allow_html="
.intval($this->allow_html).",
allow_smileys="
.intval($this->allow_smileys).",
allow_bbcode="
.intval($this->allow_bbcode).",
hometext='"
.$hometext."',
bodytext='"
.$bodytext."',
counter=0,
topicid="
.intval($this->topicid).",
ihome="
.intval($this->ihome).",
notifypub="
.intval($this->notifypub).",
type='"
.$this->type."',
topicdisplay=
$this->topicdisplay,
topicalign='"
.$this->topicalign."',
tegi='"
.$tegi."'";
}
} else {
if (
$this->approved) {
$sql "
UPDATE "
.$this->table." SET
title='"
.$title."',
published="
.$this->published.",
allow_html="
.intval($this->allow_html).",
allow_smileys="
.intval($this->allow_smileys).",
allow_bbcode="
.intval($this->allow_bbcode).",
hometext='"
.$hometext."',
bodytext='"
.$bodytext."',
topicid="
.intval($this->topicid).",
ihome="
.intval($this->ihome).",
topicdisplay="
.$this->topicdisplay.",
topicalign='"
.$this->topicalign."',
tegi='"
.$tegi."'
WHERE storyid="
.$this->storyid."";
} else {
$sql "
UPDATE "
.$this->table." SET
title='"
.$title."',
allow_html="
.intval($this->allow_html).",
allow_smileys="
.intval($this->allow_smileys).",
allow_bbcode="
.intval($this->allow_bbcode).",
hometext='"
.$hometext."',
bodytext='"
.$bodytext."',
topicid="
.intval($this->topicid).",
ihome="
.intval($this->ihome).",
topicdisplay="
.$this->topicdisplay.",
topicalign='"
.$this->topicalign."',
tegi='"
.$tegi."'
WHERE storyid="
.$this->storyid."";
}
}
if (!
$result $db->query($sql)) {
return 
false;
}
return 
true;

2) отркываем /modules/news/admin/index.php
находим строку
PHP код:
$type $_REQUEST['type']; 
после нее добавляем
PHP код:
$tegi $_REQUEST['tegi']; 
в case "edit" после
PHP код:
$topicdisplay  $story->topicdisplay(); 
добавляем
PHP код:
$tegi       $story->tegi(); 
в case "save" после
PHP код:
$story->setTopicdisplay($topicdisplay); 
добавляем
PHP код:
$story->settegi($tegi); 
3) открываем /modules/news/admin/storyform.inc.php
тут я ничего не стал менять, просто добавил как было у Usama, но вы можете пофантазировать, указанные файлы добавил отдельным архивом, хотя, думаю, что они и не нужны.
после
PHP код:
else
{
$xt->makeTopicSelBox(00"topicid");

добавляем это
PHP код:
?>
</td></tr><tr><td>
<table width='99%' border='0' cellspacing='0' cellpadding='0' summary=''>
<tr>
<td class = 'optable' >
<link rel="stylesheet" type="text/css" href="/modules/news/css/admin.css" />
<link rel="stylesheet" type="text/css" href="/modules/news/css/jquery-ui/jquery-ui-1.8.6.custom.css" />
<link rel="stylesheet" media="screen" type="text/css" href="/modules/news/css/jquery.alerts.css" />
<link rel="stylesheet" media="screen" type="text/css" href="/modules/news/css/jquery.lightbox-0.5.css" />
<style type="text/css">
#addtegiTable {width: 16px;     height: 16px; background: url(images/add.png); float:right; cursor: pointer;}
#deletetegiTable {width: 16px; height: 16px; background: url(images/delete_line.png); float:right; cursor: pointer;}
</style>
<script type="text/javascript" src="/modules/news/js/jquery-ui.js"></script>
<script type="text/javascript" src="/modules/news/js/jquery.alerts.js"></script>
<script type="text/javascript" src="/modules/news/js/jquery.lightbox-0.5.js"></script>
<script type="text/javascript"> 
jQuery(function() {
jQuery( "#tabs" ).tabs();
jQuery("a[rel='lightbox']").lightBox(); 
});
</script><br />
<div id="tabs-3"> <script type="text/javascript">
<!--
function xoopsFormValidate_tegi_form()
{
var form = $('tegi_form');}
//-->
</script>
<table border='0' cellpadding='2' cellspacing='1' width='100%' class='bg4'>
<tr><td> <b>Теги к статье</b> </td>
<td class='bg1'>
<div id="div_tegi_table">
<table id="tegi_table"><tr>
<td><input class="file" name="tegi" type="text" size="130" value="<?php echo $tegi;?>"></td></tr>
</table></div></div></td></tr></table>
</td></tr><tr><td>
<?
4) открываем /modules/news/class/class.newsstory.php,
и добавляем эту функцию для аккуратности к верхним функциям
PHP код:
function getAllPublishedTegi($limit 0$start 0$topic 0$ihome 0$asobject true)
{
global 
$db$myts;
$tegi=$_GET['teg'];
$ret = array();
$sql "SELECT a.*, b.uname, c.* FROM  ".NEWS_STORIES_TBL." a LEFT JOIN  " NEWS_TOPICS_TBL " c ON a.topicid =c.topic_id LEFT JOIN " RC_USERS_TBL " b ON a.uid =b.uid WHERE a.published > 0 AND a.published <= " time() . " AND tegi like '%".$tegi."%'";
if ( !empty(
$topic) )
{
$sql .= " AND a.topicid=" intval($topic) . " AND (a.ihome=1 OR a.ihome=0)";
}
else
{
if ( 
$ihome == )
{
$sql .= " AND a.ihome=0";
}
}
$sql .= " ORDER BY a.published DESC";
$result $db->query($sqlintval($limit), intval($start));
while ( 
$myrow $db->fetch_array($result) )
{
if ( 
$asobject )
{
$ret[] = new NewsStory($myrow);
}
else
{
$ret[$myrow['storyid']] = $myts->makeTboxData4Show($myrow['title']);
}
}
return 
$ret;

а это добавляем к нижним функциям
PHP код:
   function tegi() {
if ( 
$this->tegi!='' ) {
$ret $this->tegi;
}
return 
$ret;

5) открываем /modules/news/article.php
и после
PHP код:
$imglink "";
if ( 
$story->topicdisplay() )
{
$imglink $story->imglink();

добавляем
PHP код:
$tegis  $story->tegi();
if(
$tegis!=''){
$tegis=explode(',',$tegis);
foreach(
$tegis as $teg) {
$tegi.="<a href='/modules/news/tegi.php?teg=".$teg."'>".$teg."</a>,&nbsp;";
}

в строку themenews добавляем $tegi, и строка будет такой
PHP код:
themenews($poster$datetime$title$story->counter(), $bodytext$imglink$tegi$adminlink$pagenav); 
Как вы поняли место вывода формирует футкция themenews в файле theme.php в папке темы. А там уже конкретно morelink, можете придать любой вид.
В админке тэги разделять запятой и после запятого не ставить пробель, пример: Спорт,Футбол,Зимные виды,Прыжки в длину,Хоккей, Баскетбол и т.д.т.п.
В папке модуля можно под себя настроит и файл tegi.php.
Вот и все. Проверяйте на локалке, потом уже на рабочем сайте.

  Сообщения: 184 c 14.11.2005 | Репутация: 3
Lover_N001 вне форума Lover_N001
Участник


| Цитировать Старый #2 12-20-2012, 15:20

После этого можно красиво организовать блок вывода тэгов, буду благодарен если кто сделает. А сам еще раз благодарю Usama.

  Сообщения: 184 c 14.11.2005 | Репутация: 3
Ответ

Опции темы
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход


Рейтинг@Mail.ru Хостинг провайдер Majordomo. Powered by: vBulletin Version 3.0
Copyright ©2000-2024, Jelsoft Enterprises Ltd.
Все разделы прочитаны - Руководство форума - Архив - Вверх
Rambler's Top100
Output: 85.26 Kb. compressed to 82.77 Kb. by saving 2.49 Kb. (2.92%)
Page generated in 0.06857 seconds with 12 queries