Отображение всех статей пользователя

+3
3.36K
Иллюстрация

Открыть \components\users\frontend.php
Найти
  1.  
  2. $usr['comments_count'] = (int)$inDB->rows_count('cms_comments', "user_id=$id AND published=1");
  3.  
Добавить после
  1.  
  2. $usr['articles_count'] = (int)$inDB->rows_count('cms_content', "user_id=$id AND published=1");
  3.  


Открыть \templates\_default_\components\com_users_profile.tpl
Найти
  1.  
  2. {if $cfg.sw_board}
  3. <div id="usr_board">
  4. <a href="/users/{$usr.id}/board.html">{$LANG.ADVS}</a> ({$usr.board_count})
  5. </div>
  6. {/if}
  7.  
Добавить после
  1.  
  2. <div id="usr_articles">
  3. <a href="/my-{$usr.id}.html">Статей</a> ({$usr.articles_count})
  4. </div>
  5.  

Открыть \components\content\frontend.php
Найти
  1.  
  2. if ($do=='my'){
  3.  
  4. if (!$inCore->isUserCan('content/add')){
  5.  
Заменить
  1.  
  2. if ($do=='my'){
  3.  
  4. if (!$inCore->isUserCan('content/add') && (!isset($_REQUEST['user_id']) || $_REQUEST['user_id'] < 1)){
  5.  

Найти
  1.  
  2. $user_id = $inUser->id;
  3.  
  4. $inPage->setTitle($_LANG['MY_ARTICLES']);
  5. $inPage->addPathway($_LANG['MY_ARTICLES']);
  6.  
  7. $inPage->printHeading($_LANG['MY_ARTICLES']);
  8.  
Заменить
  1.  
  2. if(empty($_REQUEST['page']))
  3. $_REQUEST['page'] = 1;
  4.  
  5. $page_url = '';
  6. $canEdit = false;
  7. if($_REQUEST['user_id'] > 0)
  8. {
  9. $user_id = (int)$_REQUEST['user_id'];
  10. $query = "SELECT nickname
  11. FROM cms_users
  12. WHERE id = '".$user_id."'";
  13. if($res = $inDB->query($query))
  14. {
  15. $row = $inDB->fetch_assoc($res);
  16.  
  17. $mytitle = "Статті користувача - ".$row['nickname'];
  18.  
  19. $inPage->setTitle($mytitle);
  20. $inPage->addPathway($mytitle);
  21. $inPage->printHeading($mytitle);
  22.  
  23. $page_url = '-'.$user_id;
  24. }
  25. else
  26. {
  27. $inPage->setTitle($_LANG['MY_ARTICLES']);
  28. $inPage->addPathway($_LANG['MY_ARTICLES']);
  29. $inPage->printHeading($_LANG['MY_ARTICLES']);
  30. $user_id = $inUser->id;
  31. }
  32.  
  33. }
  34. else
  35. {
  36. $user_id = $inUser->id;
  37. $inPage->setTitle($_LANG['MY_ARTICLES']);
  38. $inPage->addPathway($_LANG['MY_ARTICLES']);
  39. $inPage->printHeading($_LANG['MY_ARTICLES']);
  40.  
  41. $canEdit = true;
  42. }
  43.  

Найти
  1.  
  2. $smarty->assign('pagebar', cmsPage::getPagebar($total, $page, $perpage, '/content/my%page%.html'));
  3.  
Заменить
  1.  
  2. $smarty->assign('canEdit', $canEdit);
  3. $smarty->assign('pagebar', cmsPage::getPagebar($total, $page, $perpage, '/content/my%page%'.$page_url.'.html'));
  4.  

Открыть \components\content\router.php
Найти
  1.  
  2. //RewriteRule ^content/my.html$ /index.php?view=content&do=my&page=1
  3. $routes[] = array(
  4. '_uri' => '/^content\/my.html$/i',
  5. 'do' => 'my',
  6. 1 => 'page'
  7. );
  8.  
  9. //RewriteRule ^content/my([0-9]*).html$ /index.php?view=content&do=my&page=$1
  10. $routes[] = array(
  11. '_uri' => '/^content\/my([0-9]+).html$/i',
  12. 'do' => 'my',
  13. 1 => 'page'
  14. );
  15.  
Заменить
  1.  
  2. //RewriteRule ^content/my.html$ /index.php?view=content&do=my&page=1
  3. $routes[] = array(
  4. '_uri' => '/^content\/my.html$/i',
  5. 'do' => 'my'
  6. );
  7.  
  8. $routes[] = array(
  9. '_uri' => '/^content\/my-([0-9]+).html$/i',
  10. 'do' => 'my',
  11. 1 => 'user_id'
  12. );
  13.  
  14. //RewriteRule ^content/my([0-9]*).html$ /index.php?view=content&do=my&page=$1
  15. $routes[] = array(
  16. '_uri' => '/^content\/my([0-9]+).html$/i',
  17. 'do' => 'my',
  18. 1 => 'page'
  19. );
  20.  
  21. $routes[] = array(
  22. '_uri' => '/^content\/my([0-9]+)-([0-9]+).html$/i',
  23. 'do' => 'my',
  24. 1 => 'page',
  25. 2 => 'user_id'
  26. );
  27.  

Открыть \templates\_default_\components\com_content_my.tpl

Найти
  1.  
  2. <td width="50" class="td" align="center"><strong>{$LANG.ACTION}</strong></td>
  3.  
Заменить
  1.  
  2. {if $canEdit || $user_can_delete}
  3. <td width="50" class="td" align="center"><strong>{$LANG.ACTION}</strong></td>
  4. {/if}
  5.  

Найти
  1.  
  2. <td class="{$article.class}" align="center">
  3. <a href="/content/edit{$article.id}.html" title="{$LANG.EDIT}"><img src="/admin/images/actions/edit.gif" /></a>
  4. {if $user_can_delete}
  5. <a href="javascript:deleteArticle({$article.id})" title="{$LANG.DELETE}"><img src="/admin/images/actions/delete.gif" /></a>
  6. {/if}
  7. </td>
  8.  
Заменить
  1.  
  2. {if $canEdit || $user_can_delete}
  3. <td class="{$article.class}" align="center">
  4. {if $canEdit}
  5. <a href="/content/edit{$article.id}.html" title="{$LANG.EDIT}"><img src="/admin/images/actions/edit.gif" /></a>
  6. {/if}
  7. {if $user_can_delete}
  8. <a href="javascript:deleteArticle({$article.id})" title="{$LANG.DELETE}"><img src="/admin/images/actions/delete.gif" /></a>
  9. {/if}
  10. </td>
  11. {/if}
  12.  
+2
nikolas nikolas 13 лет назад #
не пойму зачем это нужно если и так есть вкладка статью в профиле пользователя..и все статьи видны
0
Fuze Fuze 13 лет назад #
там не все статьи

Еще от автора

Делаем украинский ЧПУ на сайте
Открываем файл core/cms.
Используя этот сайт, вы соглашаетесь с тем, что мы используем файлы cookie.