Помогите с dalance

Тема в разделе "Open Source", создана пользователем berezatara, 4 фев 2010.

Статус темы:
Закрыта.
Модераторы: Amazko, Aste
  1. berezatara

    berezatara Постоялец

    Регистр.:
    5 мар 2009
    Сообщения:
    136
    Симпатии:
    25
    Всем добрый сдрасте.

    Перейти по ссылке
    вот его оналог, только без кнопки news.
    Понадобилось вывести в основном меню кнопку "News" возле кнопок "Блоги", "Статьи" по их же принципу т.е. в базе данных есть таблица "news" есть в папке include/articles.php который выводит список статей.
    Если взять его за основу и изменить под другую таблицу из BD(аналогичную news), то будет это работать и выводить новости?
    Вот переделаный скрипт, он выводит список, но при выборе статьи из списка, не переходит к новости.

    <?
    // current article
    if (
    isset($modes[1]) && isset($modes[2]) &&
    $user_r = @mysql_fetch_object(mysql_query("SELECT * FROM {$engine["tables_ar"]["users"]} WHERE login='{$modes[1]}' and active='1'")
    )
    {
    if ($r = @mysql_fetch_object(mysql_query("SELECT * FROM {$engine["tables_ar"]["news"]} WHERE id='".(int)$modes[2]."' and user_id='$user_r->id' and visible='1'"))
    {
    $tpl->define(array(
    "page" => "$l/pages/new_details/content.htm",
    "comment_link" => "$l/pages/new_details/comment_link.htm",

    "tag_item" => "$l/pages/news/tag_item.htm",

    "comment_row" => "$l/pages/comments/comment_row.htm",
    "comment_vip" => "$l/pages/comments/comment_vip.htm",
    "comment_form" => "$l/pages/comments/comment_form.htm",
    ));

    if (!$user_r->avatar || !$user_r->avatar_w || !$user_r->avatar_h)
    {
    $user_r->avatar = $default_avatar;
    $user_r->avatar_w = $default_avatar_w;
    $user_r->avatar_h = $default_avatar_h;
    }
    else
    {
    $user_r->avatar = $avatars_pics_folder.get_1000_path($user_r->id).$user_r->avatar;
    }

    $tpl->assign(array(
    "ARTICLE_USER_ID" => $user_r->id,
    "ARTICLE_USER_LOGIN" => strtolower($user_r->login),
    "ARTICLE_USER_NAME" => str_out("$user_r->last_name $user_r->first_name",
    "ARTICLE_USER_HREF" => "users/".strtolower($user_r->login)."/",
    "ARTICLE_USER_AVATAR" => $user_r->avatar,
    "ARTICLE_USER_AVATAR_W" => $user_r->avatar_w,
    "ARTICLE_USER_AVATAR_H" => $user_r->avatar_h,

    "ARTICLE_ID" => $r->id,
    "ARTICLE_DATE" => date("d.m.Y", $r->date),
    "ARTICLE_TIME" => date("H:i", $r->date),
    "ARTICLE_TITLE" => str_out($r->title),
    // "ARTICLE_CONTENT" => nl2br(str_out($r->content)),
    "ARTICLE_CONTENT" => stripslashes($r->content),
    ));

    if ($user_r->rank == "vip"
    $tpl->parse("ARTICLE_VIP", "comment_vip";

    // tags
    $tags_id_ar = array();
    $article_tag_rs = mysql_query("SELECT * FROM {$engine["tables_ar"]["article_tags"]} WHERE article_id='$r->id'";
    while ($article_tag_rs && $article_tag_r = mysql_fetch_object($article_tag_rs))
    {
    $tags_id_ar[] = $article_tag_r->tag_id;
    }

    $tpl->clear_parse("TAG_ITEMS";
    $tag_rs = mysql_query("SELECT * FROM {$engine["tables_ar"]["tags"]} WHERE id in ('".join("','", $tags_id_ar)."')";
    while ($tag_rs && $tag_r = mysql_fetch_object($tag_rs))
    {
    $tpl->assign(array(
    "TAG_HREF" => "{$types_to_clean_titles_ar["news"]}/tag/$tag_r->clean_title/",
    "TAG_TAG" => stripslashes($tag_r->$tag_var),
    ));

    $tpl->parse("TAG_ITEMS", ".tag_item";
    }
    //

    // comments
    $comments = new diCommentsTree($engine["tables_ar"]["comments"], "news", $r->id, "print_comment";
    $comments->go();
    //

    if ($tpl->get_assigned("COMMEN
    T_ROWS")
    {
    $tpl->parse("COMMENT_LINK", "comment_link";
    }

    $tpl->assign(array(
    "COMMENT_TYPE" => "article",
    "COMMENT_TARGET_ID" => $r->id,
    "COMMENT_PARENT" => -1,
    ));
    $tpl->parse("COMMENT_FORM", "comment_form";

    // global stuff
    $the_content_r = @mysql_fetch_object(mysql_query("SELECT * FROM {$engine["tables_ar"]["content"]} WHERE type='article_details' LIMIT 1");

    if ($the_content_r)
    {
    $tpl->assign(array(
    "PAGE_TITLE" => stripslashes($the_content_r->$title_var).str_out(": {$r->title}",
    "HTML_TITLE" => str_out("{$the_content_r->$html_title_var}: {$r->title}",
    "HTML_DESCRIPTION" => str_out("{$the_content_r->$html_description_var} {$r->title}",
    "HTML_KEYWORDS" => str_out("{$the_content_r->$html_keywordz_var} {$r->title}",
    ));
    }
    //
    }
    else
    {
    $tpl->define(array(
    "page" => "$l/pages/user.htm",
    ));

    $tpl->assign(array(
    "PAGE_CONTENT" => "Такой статьи не существует",
    ));
    }
    }
    // articles list
    else
    {
    $tpl->define(array(
    "page" => "$l/pages/news/content.htm",
    "article_row" => "$l/pages/news/new_row.htm",
    "tag_item" => "$l/pages/news/tag_item.htm",

    "tag_group_row" => "$l/pages/tags/tag_group_row.htm",
    "tag_item_row" => "$l/pages/tags/tag_item_row.htm",
    "tag_table" => "$l/pages/tags/tag_table.htm",
    "tag_td" => "$l/pages/tags/tag_td.htm",
    ));

    $article_id_ar = array();
    $where_s = "";

    // articles by tag
    if (isset($modes[1]) && $modes[1] == "tag" && !empty($modes[2]))
    {
    $tag_r = @mysql_fetch_object(mysql_query("SELECT * FROM {$engine["tables_ar"]["tags"]} WHERE clean_title='{$modes[2]}'");

    if ($tag_r)
    {
    // articles ids
    $pt_rs = mysql_query("SELECT DISTINCT article_id FROM {$engine["tables_ar"]["article_tags"]} WHERE tag_id='$tag_r->id'";
    while ($pt_rs && $pt_r = mysql_fetch_object($pt_rs))
    {
    $article_id_ar[] = $pt_r->article_id;
    }
    //

    $tpl->assign(array(
    "PAGE_TITLE" => $tpl->get_assigned("PAGE_TITLE".str_out(": {$tag_r->$tag_var}",
    "HTML_TITLE" => $tpl->get_assigned("HTML_TITLE".str_out(": {$tag_r->$tag_var}",
    "HTML_DESCRIPTION" => $tpl->get_assigned("HTML_DESCRIPTION".str_out(": {$tag_r->$tag_var}",
    "HTML_KEYWORDS" => $tpl->get_assigned("HTML_KEYWORDS".str_out(": {$tag_r->$tag_var}",
    ));
    }
    }
    // articles by tag group
    /*
    elseif (isset($modes[1]) && $modes[1] == "tags" && !empty($modes[2]))
    {
    $tag_group_r = @mysql_fetch_object(mysql_query("SELECT * FROM {$engine["tables_ar"]["tag_groups"]} WHERE clean_title='{$modes[2]}'");

    if ($tag_group_r)
    {
    $tag_rs = mysql_query("SELECT * FROM {$engine["tables_ar"]["tags"]} WHERE group_id='{$tag_group_r->id}'";

    $tags_id_ar = array();
    while ($tag_rs && $tag_r = mysql_fetch_obje
    ct($tag_rs))
    {
    $tags_id_ar[] = $tag_r->id;
    }

    // articles ids
    $pt_rs = mysql_query("SELECT DISTINCT article_id FROM {$engine["tables_ar"]["article_tags"]} WHERE tag_id in join('".join("','", $tags_id_ar)."')";
    while ($pt_rs && $pt_r = mysql_fetch_object($pt_rs))
    {
    $article_id_ar[] = $pt_r->article_id;
    }
    //

    $tpl->assign(array(
    "PAGE_TITLE" => $tpl->get_assigned("PAGE_TITLE".str_out(": {$tag_group_r->$name_var}",
    "HTML_TITLE" => $tpl->get_assigned("HTML_TITLE".str_out(": {$tag_group_r->$name_var}",
    "HTML_DESCRIPTION" => $tpl->get_assigned("HTML_DESCRIPTION".str_out(": {$tag_group_r->$name_var}",
    "HTML_KEYWORDS" => $tpl->get_assigned("HTML_KEYWORDS".str_out(": {$tag_group_r->$name_var}",
    ));
    }
    }
    */
    // articles of user
    elseif (isset($modes[1]) && $user_r = @mysql_fetch_object(mysql_query("SELECT * FROM {$engine["tables_ar"]["users"]} WHERE login='{$modes[1]}' and active='1'"))
    {
    $where_s = " and user_id='$user_r->id'";

    $tpl->assign(array(
    "PAGE_TITLE" => $tpl->get_assigned("PAGE_TITLE".str_out(" {$user_r->login}",
    "HTML_TITLE" => $tpl->get_assigned("HTML_TITLE".str_out(" {$user_r->login}",
    "HTML_DESCRIPTION" => $tpl->get_assigned("HTML_DESCRIPTION".str_out(" {$user_r->login}",
    "HTML_KEYWORDS" => $tpl->get_assigned("HTML_KEYWORDS".str_out(" {$user_r->login}",
    ));
    }
    // all articles list
    else
    {
    //$show_da_ring = true;
    // nothing special for articles
    }

    if (count($article_id_ar))
    $where_s .= " and id in ('".join("','", $article_id_ar)."')";

    // printing out articles list
    $rs = mysql_query("SELECT * FROM {$engine["tables_ar"]["news"]} WHERE visible='1' $where_s ORDER BY order_num ASC";
    while ($rs && $r = mysql_fetch_object($rs))
    {
    // user
    $user_r = @mysql_fetch_object(mysql_query("SELECT * FROM {$engine["tables_ar"]["users"]} WHERE id='$r->user_id'");
    //

    // tags
    $tags_id_ar = array();
    $article_tag_rs = mysql_query("SELECT * FROM {$engine["tables_ar"]["article_tags"]} WHERE article_id='$r->id'";
    while ($article_tag_rs && $article_tag_r = mysql_fetch_object($article_tag_rs))
    {
    $tags_id_ar[] = $article_tag_r->tag_id;
    }

    $tpl->clear_parse("TAG_ITEMS";
    $tag_rs = mysql_query("SELECT * FROM {$engine["tables_ar"]["tags"]} WHERE id in ('".join("','", $tags_id_ar)."')";
    while ($tag_rs && $tag_r = mysql_fetch_object($tag_rs))
    {
    $tpl->assign(array(
    "TAG_HREF" => "{$types_to_clean_titles_ar["articles"]}/tag/$tag_r->clean_title/",
    "TAG_TAG" => stripslashes($tag_r->$tag_var),
    ));

    $tpl->parse("TAG_ITEMS", ".tag_item";
    }
    //

    // comments
    $comments_r = @mysql_fetch_object(mysql_query("SELECT COUNT(id) AS cc FROM {$engine["tables_ar"]["comments"]} WHERE type='article' and target_id=
    '$r->id' and visible='1'");
    //

    $tpl->assign(array(
    "ARTICLE_TIME" => date("H:i", $r->date),
    "ARTICLE_DATE" => date("d.m.Y", $r->date),
    "ARTICLE_HREF" => "{$types_to_clean_titles_ar["articles"]}/".strtolower($user_r->login)."/{$r->id}/",
    "ARTICLE_TITLE" => str_out($r->title),
    "ARTICLE_CONTENT" => str_cut_end(str_out(strip_tags($r->content)), 400),
    "ARTICLE_COMMENTS_COUNT"=> (int)$comments_r->cc,

    "USER_ID" => $user_r->id,
    "USER_HREF" => "users/".strtolower($user_r->login)."/",
    "USER_FIRST_NAME" => str_out($user_r->first_name),
    "USER_LAST_NAME" => str_out($user_r->last_name),
    ));
    $tpl->parse("ARTICLE_ROWS", ".article_row";
    }
    //

    // rss
    $tpl->assign(array(
    "RSS_WHAT" => "articles",
    ));
    $tpl->parse("RSS_BTN", "rss_btn";
    $tpl->assign(array(
    "PAGE_TITLE" => $tpl->get_assigned("PAGE_TITLE"." ".$tpl->fetch("RSS_BTN",
    ));
    //
    }
    //

    $tpl->parse("PAGE","page";
    ?>

    Может кто нить помоч.
     
  2. Jigsaff

    Jigsaff Постоялец

    Регистр.:
    17 июн 2006
    Сообщения:
    103
    Симпатии:
    11
    А где взять-то его, это скрипт? Он есть в паблике?
     
Статус темы:
Закрыта.