Jump to content

A common variable share by Parent forum and its subforums


Recommended Posts

Hi Guys :) On my site I have two forum 1 and forum 2. Under Forum 1 there are 15 another subforums. I would to like to hide author name tumbnail next to topic Title only for Forum 1 and all its subforums not for Forum 2.  I am trying to implement this by Html Logic  MY Problem is i have to put every 15 forums ids inside the code to work it properly. right now i am looking for single global variable that is shared by a forum and its subforums so it with single line of code it works

Link to comment
Share on other sites

{{if $forum->id == X or $forum->parent_id == X}}

Or if you want to make it infinitely recursive (so it also extends to subforums of subforums of forum A):

{{if $forum->id == X or $forum->isChildOf( \IPS\forums\Forum::load( X ) )}}

That will have a non-negligable performance hit though (it will increase linearly with how deep the forum is) 

Link to comment
Share on other sites

Hi @Mark Thanks for reply :) I am trying  to implement your suggested method to Remove the Topic Author details Box   only for one specific forum and its subforums not for other forums. For other forums and its subforums topic author detail box is shown as first comment 




Id of a Forum  for what i would like to implement is 5

i put following code inside Forums -> Front -> Topics -> PostContainer  to implement my scenario

{{if ! $comment->mapped('first') and ($forum->id == 5 or $forum->parent_id == 5)}}

<aside class='ipsComment_author cAuthorPane ipsColumn ipsColumn_medium ipsResponsive_hidePhone'>
		<h3 class='ipsType_sectionHead cAuthorPane_author ipsType_blendLinks ipsType_break'><strong>{$comment->author()->link( $comment->warningRef() )|raw}</strong> <span class='ipsResponsive_showPhone ipsResponsive_inline'>  {template="reputationBadge" group="global" app="core" params="$comment->author()"}</span></h3>
		<ul class='cAuthorPane_info ipsList_reset'>
			{{if $comment->author()->member_title && $comment->author()->member_id}}
				<li class='ipsType_break'>{$comment->author()->member_title}</li>
			{{elseif $comment->author()->rank['title'] && $comment->author()->member_id}}
				<li class='ipsType_break'>{$comment->author()->rank['title']}</li>
			{{if $comment->author()->rank['image'] && $comment->author()->member_id}}

			<li class='cAuthorPane_photo'>
				{template="userPhoto" app="core" group="global" params="$comment->author(), 'large', $comment->warningRef()"}
			<li>{expression="\IPS\Member\Group::load( $comment->author()->member_group_id )->formattedName" raw="true"}</li>
			{{if \IPS\Member\Group::load( $comment->author()->member_group_id )->g_icon }}
				<li><img src='{file="$comment->author()->group['g_icon']" extension="core_Theme"}' alt='' class='cAuthorGroupIcon'></li>
			{{if $comment->author()->member_id}}
				<li>{template="reputationBadge" group="global" app="core" params="$comment->author()"}</li>
				<li class='ipsType_light'>{lang="member_post_count" pluralize="$comment->author()->member_posts"}</li>
				{{if $comment->author()->reputationImage()}}
					<li class='ipsPad_half'>
						<img src='{file="$comment->author()->reputationImage()" extension="core_Theme"}' title='{{if $comment->author()->reputation()}}{$comment->author()->reputation()}{{endif}}' alt=''>
				{template="customFieldsDisplay" group="global" app="core" params="$comment->author()"}

 But it is not working :sad: could you please help me. I am just beginner in programming 


Link to comment
Share on other sites

The reason it isn't working is because in postContainer, there is no $forum variable declared:


So this cannot evaluate.....

{{if ! $comment->mapped('first') and ($forum->id == 5 or $forum->parent_id == 5)}}


This will get you the forum id of a post in a topic in a forum:


This will get you the parent forum id of a post in a topic in a subforum:


This should work for you:

{{if(!$comment->mapped('first') AND ($comment->item()->container()->id === 2 OR $comment->item()->container()->parent_id === 2))}}



Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...