Переносим информацию из блока профиля в блок на главную!

Привет Друзья, пришла идея перенести информацию сайдбара в профиле пользователя, что бы отображались с количеством постов: Стена, Публикации, Избранное, Друзья и т.д.



Внимание! Стили произвольные, что бы оформить блок, свои стили Вы должны вставить самостоятельно!

1. Вставляем код в блок, куда нам нужно вывести информацию. В нашем случае это block.user.tpl

<section class="block block-type-profile-nav">
	<ul class="nav  nav-profile">
		{hook run='profile_sidebar_menu_item_first' oUserProfile=$oUserCurrent}
		<li {if $sAction=='profile' && ($aParams[0]=='whois' or $aParams[0]=='')}class="active"{/if}><a href="{$oUserCurrent->getUserWebPath()}">{$aLang.user_menu_profile_whois}</a></li>
		<li {if $sAction=='profile' && $aParams[0]=='wall'}class="active"{/if}><a href="{$oUserCurrent->getUserWebPath()}wall/">{$aLang.user_menu_profile_wall}{if ($iCountWallUser)>0} ({$iCountWallUser}){/if}</a></li>
		<li {if $sAction=='profile' && $aParams[0]=='created'}class="active"{/if}><a href="{$oUserCurrent->getUserWebPath()}created/topics/">{$aLang.user_menu_publication}{if ($iCountCreated)>0} ({$iCountCreated}){/if}</a></li>
		<li {if $sAction=='profile' && $aParams[0]=='favourites'}class="active"{/if}><a href="{$oUserCurrent->getUserWebPath()}favourites/topics/">{$aLang.user_menu_profile_favourites}{if ($iCountFavourite)>0} ({$iCountFavourite}){/if}</a></li>
		<li {if $sAction=='profile' && $aParams[0]=='friends'}class="active"{/if}><a href="{$oUserCurrent->getUserWebPath()}friends/">{$aLang.user_menu_profile_friends}{if ($iCountFriendsUser)>0} ({$iCountFriendsUser}){/if}</a></li>
		<li {if $sAction=='profile' && $aParams[0]=='stream'}class="active"{/if}><a href="{$oUserCurrent->getUserWebPath()}stream/">{$aLang.user_menu_profile_stream}</a></li>
		
		{if $oUserCurrent and $oUserCurrent->getId() == $oUserCurrent->getId()}
			<li {if $sAction=='talk'}class="active"{/if}><a href="{router page='talk'}">{$aLang.talk_menu_inbox}{if $iUserCurrentCountTalkNew} ({$iUserCurrentCountTalkNew}){/if}</a></li>
			<li {if $sAction=='settings'}class="active"{/if}><a href="{router page='settings'}">{$aLang.settings_menu}</a></li>
		{/if}
		{hook run='profile_sidebar_menu_item_last' oUserProfile=$oUserCurrent}
	</ul>
</section>


2. Теперь редактируем файл движка сайт.ру/classes/actions/ActionIndex.class.php d 315 строке public function EventShutdown() удаляем всё и вставляем между скобами
	if (!$this->oUserCurrent)	 {
			return ;
		}
		/**
		 * Загружаем в шаблон необходимые переменные
		 */
		$iCountTopicFavourite=$this->Topic_GetCountTopicsFavouriteByUserId($this->oUserCurrent->getId());
		$iCountTopicUser=$this->Topic_GetCountTopicsPersonalByUser($this->oUserCurrent->getId(),1);
		$iCountCommentUser=$this->Comment_GetCountCommentsByUserId($this->oUserCurrent->getId(),'topic');
		$iCountCommentFavourite=$this->Comment_GetCountCommentsFavouriteByUserId($this->oUserCurrent->getId());
		$iCountNoteUser=$this->User_GetCountUserNotesByUserId($this->oUserCurrent->getId());

		//$this->Viewer_Assign('oUserProfile',$this->oUserProfile);
		$this->Viewer_Assign('iCountTopicUser',$iCountTopicUser);
		$this->Viewer_Assign('iCountCommentUser',$iCountCommentUser);
		$this->Viewer_Assign('iCountTopicFavourite',$iCountTopicFavourite);
		$this->Viewer_Assign('iCountCommentFavourite',$iCountCommentFavourite);
		$this->Viewer_Assign('iCountNoteUser',$iCountNoteUser);
		$this->Viewer_Assign('iCountWallUser',$this->Wall_GetCountWall(array('wall_user_id'=>$this->oUserCurrent->getId(),'pid'=>null)));
		/**
		 * Общее число публикация и избранного
		 */
		$this->Viewer_Assign('iCountCreated',(($this->oUserCurrent and $this->oUserCurrent->getId()==$this->oUserCurrent->getId()) ? $iCountNoteUser : 0) +$iCountTopicUser+$iCountCommentUser);
		$this->Viewer_Assign('iCountFavourite',$iCountCommentFavourite+$iCountTopicFavourite);
		/**
		 * Заметка текущего пользователя о юзере
		 */
		if ($this->oUserCurrent) {
			$this->Viewer_Assign('oUserNote',$this->oUserCurrent->getUserNote());
		}
		$this->Viewer_Assign('iCountFriendsUser',$this->User_GetCountUsersFriend($this->oUserCurrent->getId()));

		$this->Viewer_Assign('sMenuSubItemSelect',$this->sMenuSubItemSelect);
		$this->Viewer_Assign('sMenuHeadItemSelect',$this->sMenuHeadItemSelect);
		$this->Viewer_Assign('USER_FRIEND_NULL',ModuleUser::USER_FRIEND_NULL);
		$this->Viewer_Assign('USER_FRIEND_OFFER',ModuleUser::USER_FRIEND_OFFER);
		$this->Viewer_Assign('USER_FRIEND_ACCEPT',ModuleUser::USER_FRIEND_ACCEPT);
		$this->Viewer_Assign('USER_FRIEND_REJECT',ModuleUser::USER_FRIEND_REJECT);
		$this->Viewer_Assign('USER_FRIEND_DELETE',ModuleUser::USER_FRIEND_DELETE);


3. В public function Init() добавляем:
$this->User_GetUserCurrent


4. После protected $sMenuHeadItemSelect='blog'; вставляем:
protected $oUserCurrent = null;


5. в евенте public function EventShutdown() { экранируем или удаляем:
$this->Viewer_Assign('sMenuHeadItemSelect',$this->sMenuHeadItemSelect);
		$this->Viewer_Assign('sMenuItemSelect',$this->sMenuItemSelect);
		$this->Viewer_Assign('sMenuSubItemSelect',$this->sMenuSubItemSelect);
		$this->Viewer_Assign('iCountTopicsNew',$this->iCountTopicsNew);
		$this->Viewer_Assign('iCountTopicsCollectiveNew',$this->iCountTopicsCollectiveNew);


5. Далее что бы этот блок был актуальным для всех страниц нашего сайта, добавляем в остальные экшены папки actions, в public function EventShutdown()
/*$iCountTopicFavourite=$this->Topic_GetCountTopicsFavouriteByUserId($this->oUserProfile->getId());
        $iCountTopicUser=$this->Topic_GetCountTopicsPersonalByUser($this->oUserProfile->getId(),1);
        $iCountCommentUser=$this->Comment_GetCountCommentsByUserId($this->oUserProfile->getId(),'topic');
        $iCountCommentFavourite=$this->Comment_GetCountCommentsFavouriteByUserId($this->oUserProfile->getId());
        $iCountNoteUser=$this->User_GetCountUserNotesByUserId($this->oUserProfile->getId());
		
		$this->Viewer_Assign('sMenuHeadItemSelect',$this->sMenuHeadItemSelect);
		$this->Viewer_Assign('sMenuItemSelect',$this->sMenuItemSelect);
		$this->Viewer_Assign('sMenuSubItemSelect',$this->sMenuSubItemSelect);
		$this->Viewer_Assign('iCountTopicsNew',$this->iCountTopicsNew);
		$this->Viewer_Assign('iCountTopicsCollectiveNew',$this->iCountTopicsCollectiveNew);
		$this->Viewer_Assign('iCountTopicsPersonalNew',$this->iCountTopicsPersonalNew);*/

if (!$this->oUserCurrent)	 {
			return ;
		}
		/**
		 * Загружаем в шаблон необходимые переменные
		 */
		$iCountTopicFavourite=$this->Topic_GetCountTopicsFavouriteByUserId($this->oUserCurrent->getId());
		$iCountTopicUser=$this->Topic_GetCountTopicsPersonalByUser($this->oUserCurrent->getId(),1);
		$iCountCommentUser=$this->Comment_GetCountCommentsByUserId($this->oUserCurrent->getId(),'topic');
		$iCountCommentFavourite=$this->Comment_GetCountCommentsFavouriteByUserId($this->oUserCurrent->getId());
		$iCountNoteUser=$this->User_GetCountUserNotesByUserId($this->oUserCurrent->getId());

		//$this->Viewer_Assign('oUserProfile',$this->oUserProfile);
		$this->Viewer_Assign('iCountTopicUser',$iCountTopicUser);
		$this->Viewer_Assign('iCountCommentUser',$iCountCommentUser);
		$this->Viewer_Assign('iCountTopicFavourite',$iCountTopicFavourite);
		$this->Viewer_Assign('iCountCommentFavourite',$iCountCommentFavourite);
		$this->Viewer_Assign('iCountNoteUser',$iCountNoteUser);
		$this->Viewer_Assign('iCountWallUser',$this->Wall_GetCountWall(array('wall_user_id'=>$this->oUserCurrent->getId(),'pid'=>null)));
		/**
		 * Общее число публикация и избранного
		 */
		$this->Viewer_Assign('iCountCreated',(($this->oUserCurrent and $this->oUserCurrent->getId()==$this->oUserCurrent->getId()) ? $iCountNoteUser : 0) +$iCountTopicUser+$iCountCommentUser);
		$this->Viewer_Assign('iCountFavourite',$iCountCommentFavourite+$iCountTopicFavourite);
		/**
		 * Заметка текущего пользователя о юзере
		 */
		if ($this->oUserCurrent) {
			$this->Viewer_Assign('oUserNote',$this->oUserCurrent->getUserNote());
		}
		$this->Viewer_Assign('iCountFriendsUser',$this->User_GetCountUsersFriend($this->oUserCurrent->getId()));

		$this->Viewer_Assign('sMenuSubItemSelect',$this->sMenuSubItemSelect);
		$this->Viewer_Assign('sMenuHeadItemSelect',$this->sMenuHeadItemSelect);
		$this->Viewer_Assign('USER_FRIEND_NULL',ModuleUser::USER_FRIEND_NULL);
		$this->Viewer_Assign('USER_FRIEND_OFFER',ModuleUser::USER_FRIEND_OFFER);
		$this->Viewer_Assign('USER_FRIEND_ACCEPT',ModuleUser::USER_FRIEND_ACCEPT);
		$this->Viewer_Assign('USER_FRIEND_REJECT',ModuleUser::USER_FRIEND_REJECT);
		$this->Viewer_Assign('USER_FRIEND_DELETE',ModuleUser::USER_FRIEND_DELETE);


Теперь прописываем свои CSS стили для оформления блока, и готово.

Особенная благодарность 1099511627776 за реализацию идеи!

6 комментариев

avatar
пример хотя бы посмотреть… Я не понял
avatar
О чем речь непонятно
avatar
Не надо рекомендовать примеры дурного кода. Обернуть весь функционал в статичный метод и подключать его в EventShutdown() нужных экшенов.
avatar
In a current advertising campaign regarding [url=http://www.airjordanonlineuk.com/nike-lebron]nike lebron uk shoes[/url], container baller Kobe Bryant allows us all a good deal of ideas with how to realize different extreme conditions connected with achievements. He shows his or her process intended for over-the-top being successful before a closed society target market, such as rapper Kanye Western world and billionaire Richard Branson, at production which is just like a amalgam on the Masonic routine and also a TED Talk.

Buy shoes or boots comprehensive by the far east «How did you know if you are inside Kobe Technique? » Bryant requests. «Look with your feet. » The natural way, they really are most putting on [url=http://www.airjordanonlineuk.com/nike-lebron/nike-lebron-10]nike lebron 10 for sale[/url]. Thus you need renowned prizes, Purchase air flow greatest extent by china you happen to be a new Chinese language megastar, and also probably you possess outside room: absolutely, meaning you are productive. Nevertheless perhaps we should keep in mind that being successful depends on accomplishing anything target most of us established for our-self rather than if the intention will be worthy or maybe not necessarily. A number of the nearly all raw dictators throughout background could be regarded profitable inside feel which they have been powerful commanders, but they would almost never deserve to become designed into a new pedestal.
avatar
It can be revealed for the full planet which Nike can be a well-known name, which will mixes that electricity as well the development. It can be little question which nike kobe shoes or boots australia may be the biggest plus the many sturdy printed shoes and boots in which commonly situated great type and also unpaid comfort. Person's commonly have to get anything should have its purchase. Custom made Nike sneakers usually are these kinds of the kind of the goods.

Its superb productiveness in addition to excellent ease generate people today feel that this well-known manufacturer might be very worth persons' a precious reminder expenditure connected with cash and also moment. Presently posting famed in addition to good quality manufacturer, nike kobe 6 review materials wonderful collection regarding sporting activities shoes or boots which will have the ability to satisfy this needs and also essentials associated with all of us. These items employ a sporty look and feel that in general present safe as well as sophisticated looks, so it could be included in a lot of sporting activities arena. Irrespective of you will engage in golf ball or maybe soccer, presently there should be a pair of correct custom athletic shoes awaits you.

Developer nike lebron shoes and boots pertaining to sale usually are highly properly known inside known personages so are the fantastic range for individuals who're seeking brilliant along with excellent stunning boots or shoes. The actual famous manufacturer always resources some sort of stunning and also lightning guise inside the open but will assistance folks setup the amazing amount while in the guests. These kind of sizzling parts generate men and women employ a major desire as well as generate individuals enjoy the protected sense. Hence, in the event that people today may select low-priced Nike Surroundings Utmost, it will likely be some sort of quite superb range for you. Brewing up these kind of a good exclusive athletic shoes could make everyone come to be the actual awareness with folks who near to you. While everybody knows, Nike Weather Utmost game boots or shoes will be outfitted together with modern in addition to integrally household leather covered lace-up, nylon uppers upper, thought stunning shades, specific as well as formative sort, exotic material, leg household leather, hand crafted item, very best hold as well as exercise, manufactured, rubberized single skin, constructed together with ease sort, gentle lbs, trendy, quality, endurance as well as fair prices. Within a expression, the actual printed custom shoes or boots tend to be become the excellent solutions as well as treatments inside the whole earth.

By means of status with the chic workout shoes, there are plenty of destinations provide large creator Nike boots or shoes for that buyers. In the event you never discover the matched goods inside the shops, usually do not experience irritable. You will see also many on-line suppliers offered to furnish dazzling in addition to in vogue lebron 15 available for purchase cheap at cost-effective charges. Therefore, the actual level of competition among the particular at wholesale prices Nike AirMax shops is pretty intense as well as nervous, that may be fairly appreciative regarding buyers. For this reason, clients may check out different general on-line shops to examine the actual costs as well as the superb. On last, buyers can easily find any trusted as well as trustworthy on-line keep to get by far the most economical although level of quality branded workout shoes.

Summing up, buying creator kevin durant shoes or boots australia is definately any unreachable wish for that prevalent men and women. With nowadays, it is certainly straightforward for people to help searching on-line to seek available your selected shoes or boots. Just do it. You will find lesser number of custom made boots or shoes which will mixes the actual nice safe practices with all the ft and also tendency physical appearance based on a person's persona. Nike is just about the lesser number of manufacturers, as a result, having a good astonishingly less costly creator Nike shoes and boots is pretty essential.
avatar
спасибо огромное! помогло в решении
Только зарегистрированные и авторизованные пользователи могут оставлять комментарии.