Шестеренка "Новости" / Шестеренка / cogear - система управления сайтами, бесплатная cms для социальной сети http://cogear.ru/cogear-gears-news-371.html/ ru http://cogear.ru http://cogear.ru/templates/cogear/img/logo.png cogear - система управления сайтами, бесплатная cms для социальной сети <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8694 http://cogear.ru/cogear-gears-news-371.html#comment-8694 dreycorp Mon, 18 Oct 2010 20:26:05 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8687 http://cogear.ru/cogear-gears-news-371.html#comment-8687
Все получилось! :-) ]]>
inetlover Mon, 18 Oct 2010 18:39:47 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8686 http://cogear.ru/cogear-gears-news-371.html#comment-8686
Пошел делать. ]]>
inetlover Mon, 18 Oct 2010 16:58:28 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8685 http://cogear.ru/cogear-gears-news-371.html#comment-8685 dreycorp Mon, 18 Oct 2010 16:55:41 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8684 http://cogear.ru/cogear-gears-news-371.html#comment-8684 dreycorp, а не подскажешь, что это за индекс такой и где он находиться или дай, пожалуйста, наводку, как можно сделать свой? ]]> inetlover Mon, 18 Oct 2010 16:13:37 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8683 http://cogear.ru/cogear-gears-news-371.html#comment-8683 dreycorp Mon, 18 Oct 2010 13:55:15 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8681 http://cogear.ru/cogear-gears-news-371.html#comment-8681
Таблица: news_group CREATE TABLE IF NOT EXISTS `news_group` ( `id` smallint(5) unsigned NOT NULL auto_increment, `name` varchar(30) NOT NULL, `url_name` varchar(20) NOT NULL, `description` varchar(255) NOT NULL, `icon` varchar(255) NOT NULL, `created_date` timestamp NOT NULL default CURRENT_TIMESTAMP, `main` int(11) default NULL, `position` smallint(5) default NULL, PRIMARY KEY (`id`), KEY `name` (`name`,`url_name`,`description`), KEY `main` (`main`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
Хочу всего лишь сделать, что бы поля name и url_name вмещали по 70 символов:
`name` varchar(70) NOT NULL, `url_name` varchar(70) NOT NULL, Но почему-то phpMyAdmin поле name позволяет увеличить только до 56 символов, а дальше выдает ошибку: #1071 - Specified key was too long; max key length is 1000 bytes — голову сломал почему так получается, ведь в этой таблице присутствуют поля с такими же параметрами содержащие в себе по 255 символов?

Подскажите, пожалуйста, кто что знает на этот счет? ]]>
inetlover Mon, 18 Oct 2010 12:53:57 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8359 http://cogear.ru/cogear-gears-news-371.html#comment-8359 dreycorp Tue, 21 Sep 2010 16:13:14 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8357 http://cogear.ru/cogear-gears-news-371.html#comment-8357 Varhal Tue, 21 Sep 2010 15:14:40 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8356 http://cogear.ru/cogear-gears-news-371.html#comment-8356 надо после строки
if ($uri_count===1) {return array('main',0,array(),0);}; вставить
if ($uri_count==2 && is_numeric($uri[2])) {return array('main',0,array(),$uri[2]);};
в функции get переменная page будет содержать номер страницы, по умолчанию 0. ]]>
dreycorp Tue, 21 Sep 2010 14:36:20 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8354 http://cogear.ru/cogear-gears-news-371.html#comment-8354 Varhal Tue, 21 Sep 2010 13:31:06 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8344 http://cogear.ru/cogear-gears-news-371.html#comment-8344 dreycorp Tue, 21 Sep 2010 08:31:08 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8290 http://cogear.ru/cogear-gears-news-371.html#comment-8290
elseif($type=='main') { $all_node = date('Y-m-d',time()-24*60*60); $CI =& get_instance(); $count=$this->db->query("select count(id) as counter from news where published = true and created_date != $id")->row(); $count=$count->counter; $page = $CI->pager($page, $count); $this->db->select('news.*',FALSE); $this->db->select('users.avatar,users.url_name as author_url_name,users.name as author'); $this->db->join('users','users.id = news.aid','inner'); $this->db->where('news.published','true'); $this->db->order_by('news.created_date','desc'); $this->db->limit($page['limit'],$page['start']); $this->db->where('news.created_date != ',$all_node); $news=$this->db->get('news')->result(); foreach ($news as $num=>$item) { $this->show($item,'short'); } } Постраничная навигация появилась, но при нажатии на номер странички, 404(( ]]>
Varhal Sat, 18 Sep 2010 11:11:52 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8288 http://cogear.ru/cogear-gears-news-371.html#comment-8288 select count(id) as counter from news where published =true and gid=$id сделать запрос похожий на нужный

$this->db->select('count(news.id) as counter'); $this->db->where('news.published','true'); $this->db->where('news.created_date > ',$all_node); $count=$this->db->get('news')->row(); $count=$count->counter;
или в sql это
select count(id) as counter from news where published = true and created_date > $all_node
а дальше все правильно ]]>
dreycorp Sat, 18 Sep 2010 08:29:31 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8250 http://cogear.ru/cogear-gears-news-371.html#comment-8250 Varhal Thu, 16 Sep 2010 19:36:37 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8249 http://cogear.ru/cogear-gears-news-371.html#comment-8249
elseif($type=='main') { $CI =& get_instance(); $count=$this->db->query("select count(id) as counter from news where published =true and gid=$id")->row(); $count=$count->counter; $page = $CI->pager($page, $count); $all_node = date('Y-m-d',time()-24*60*60); $this->db->select('news.*',FALSE); $this->db->select('users.avatar,users.url_name as author_url_name,users.name as author'); $this->db->join('users','users.id = news.aid','inner'); $this->db->where('news.published','true'); $this->db->order_by('news.created_date','desc'); $this->db->limit($page['limit'],$page['start']); $this->db->where('news.created_date != ',$all_node); $news=$this->db->get('news')->result(); foreach ($news as $num=>$item) { $this->show($item,'short'); } } что я не правильно делаю?? ]]>
Varhal Thu, 16 Sep 2010 19:33:54 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8245 http://cogear.ru/cogear-gears-news-371.html#comment-8245 Varhal Thu, 16 Sep 2010 17:46:27 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8244 http://cogear.ru/cogear-gears-news-371.html#comment-8244 Varhal Thu, 16 Sep 2010 17:45:54 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8240 http://cogear.ru/cogear-gears-news-371.html#comment-8240 cogear.ru/user_guide/html/ Ищи «Постраничная навигация» Опоздал =) ]]> Graid Thu, 16 Sep 2010 16:17:23 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8239 http://cogear.ru/cogear-gears-news-371.html#comment-8239 cogear.ru/user_guide/gears/pagination/ еще в документации ]]> dreycorp Thu, 16 Sep 2010 16:15:25 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8237 http://cogear.ru/cogear-gears-news-371.html#comment-8237
затем в самой функции сделать
$page = $CI->pager($page, $count); $count - заранее вычисляется и содержит количество всех новостей для вывода (необходимых) теперь page это массив который содержит( в зависимости от настроек количества новостей на странице) элементы limit и start.
далее при формировании запросов к БД сделать
$this->db->limit($page['limit'],$page['start']);
пример можно посмотреть в nodes/models/nodes.php -> get(...) и у меня в шестеренке новости в антологичной функции

список страниц со ссылками появиться автоматом в низу ]]>
dreycorp Thu, 16 Sep 2010 16:12:58 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8236 http://cogear.ru/cogear-gears-news-371.html#comment-8236 Varhal Thu, 16 Sep 2010 15:44:53 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8233 http://cogear.ru/cogear-gears-news-371.html#comment-8233 dreycorp Thu, 16 Sep 2010 14:01:53 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8226 http://cogear.ru/cogear-gears-news-371.html#comment-8226 Varhal Thu, 16 Sep 2010 12:24:57 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8224 http://cogear.ru/cogear-gears-news-371.html#comment-8224 если по позиции
$this->db->order_by('news.position','asc'); - по возрастанию $this->db->order_by('news.position','desc'); - по убыванию аналогично по дате
$this->db->order_by('news.created_date','asc'); - по возрастанию $this->db->order_by('news.created_date','desc'); - по убыванию
По выводу на главной.
если в данном коде закончить
$news=$this->db->get('news')->result(); а затем вывести шаблон в котором будут выводится новости в нужном виде в шаблон передать объект $news.
$this->_template('news news_main_new(название шаблона)', array('news' => $news), false); и внутри самого шаблона foreach.

можно еще перед выводом шаблона обработать объект news через foreach и присвоить нужные дополнительные поля (link, и т.д.)

а можно в этом же foreach выводить шаблон не всех новостей сразу, а шаблон для отдельной новости, тогда соответственно второго foreach в шаблоне не надо ]]>
dreycorp Thu, 16 Sep 2010 10:06:20 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8215 http://cogear.ru/cogear-gears-news-371.html#comment-8215
$this->builder->h2(t('news today_news'),false,true); $today = date('Y-m-d', mktime(0, 0, 0, date("m") , date("d") + 0, date("Y"))); $this->db->select('news.*',FALSE); $this->db->select('users.avatar,users.url_name as author_url_name,users.name as author'); $this->db->join('users','users.id = news.aid','inner'); $this->db->where('news.published','true'); $this->db->where('news.created_date > ',$today); $this->db->order_by('news.position','asc'); $news=$this->db->get('news')->result(); foreach ($news as $num=>$item) { $this->show($item,'short'); } Вчерашние то выводятся, но вместе с ними и сегодняшние. Сортируются так же — наоборот:

$this->builder->h2(t('news last_news'),false,true); $yesterday = date('Y-m-d', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y"))); $this->db->select('news.*',FALSE); $this->db->select('users.avatar,users.url_name as author_url_name,users.name as author'); $this->db->join('users','users.id = news.aid','inner'); $this->db->where('news.published','true'); $this->db->where('news.created_date > ',$yesterday); $this->db->order_by('news.position','asc'); $news=$this->db->get('news')->result(); foreach ($news as $num=>$item) { $this->show($item,'short'); }
Еще как на главной выводить только title новостей и news_info? ]]>
Varhal Wed, 15 Sep 2010 22:58:07 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8208 http://cogear.ru/cogear-gears-news-371.html#comment-8208 Более подробно по этой теме написал в личку. ]]> inetlover Wed, 15 Sep 2010 11:59:58 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8207 http://cogear.ru/cogear-gears-news-371.html#comment-8207 dreycorp Wed, 15 Sep 2010 11:52:14 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8206 http://cogear.ru/cogear-gears-news-371.html#comment-8206
можно сделать свою функцию в модели, для отображения дерева только ссылки переделать на страницы сайта,
Если выводимое дерево устраивает, можно сделать похожий шаблон и похожую функцию (скопировать и поменять немного).
исходный шаблон называется admin_tree.tpl, можно даже немного видоизменить шаблон. ]]>
dreycorp Wed, 15 Sep 2010 11:50:03 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8199 http://cogear.ru/cogear-gears-news-371.html#comment-8199
Одна из задач, это выводить через переменную {$news} в главный файл темы header.tpl функцию tree_group_view — функция выводит дерево разделов, подобное дерево мне нужно на главной.

Создал файл _hooks.php куда поместил функцию которая будет решать поставленную задачу.

function news_header($CI){ $CI->content['news'] = $CI->news->tree_group_view(); }
В принципе задуманное работает, но терзают сомнения по поводу созданной мной функции, понимаю, что какие-нибудь плюшки для стабильной работы в ней отсутствуют.

Просьба, кто понимает, что необходимо дописать в эту функцию для стабильной и производительной работы, подскажите, пожалуйста. ]]>
inetlover Tue, 14 Sep 2010 21:46:27 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8182 http://cogear.ru/cogear-gears-news-371.html#comment-8182 Varhal Mon, 13 Sep 2010 22:46:17 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8170 http://cogear.ru/cogear-gears-news-371.html#comment-8170 inetlover Mon, 13 Sep 2010 17:27:52 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8167 http://cogear.ru/cogear-gears-news-371.html#comment-8167 Название архива news4.zip.
Обновлен файл widgets/news.php. ]]>
dreycorp Mon, 13 Sep 2010 13:54:34 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8166 http://cogear.ru/cogear-gears-news-371.html#comment-8166
Только вот виджет ничего не показывает, пишет, что: Новостей нет. ]]>
inetlover Mon, 13 Sep 2010 13:36:59 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-8151 http://cogear.ru/cogear-gears-news-371.html#comment-8151
cogear.ru/oshibka-pri-rabote-s-modulem-novosti-466.html ]]>
rismyk Sun, 12 Sep 2010 18:00:58 GMT
<![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-6324 http://cogear.ru/cogear-gears-news-371.html#comment-6324 dreycorp Mon, 12 Jul 2010 08:55:53 GMT <![CDATA[]]> http://cogear.ru/cogear-gears-news-371.html#comment-6323 http://cogear.ru/cogear-gears-news-371.html#comment-6323 inetlover Mon, 12 Jul 2010 06:26:09 GMT