Invisionize.eu - IP.Board (IPB) News

Drukowana wersja artykułu

Kliknij tutaj aby zobaczyć artykuł w oryginalnym formacie

Invisionize.eu - IP.Board (IPB) News _ Invision Power Services Beyond Forums _ Problem with "test="nosidebar:|:IPSCookie::get('hide_sidebar')"

Dodane przez: Invisionize.eu czw, 29 lipiec 2010

Ok, so this is my demo board:

http://www.arvag.net/demo

You can see recent topics and recent gallery images above all forums. In order to keep everything working when the sidebar is open i have these two css styles:

.recent_gallery_images #attach_wrap li{
margin:5px 5px !important;
}

.recent_gallery_images #attach_wrap li.no_sidebar{
margin:5px 43px !important;
}


In my "hookRecentGalleryImages" template i have this:

<div class='recent_gallery_images right category_block block_wrap'>
	<h3 class='maintitle'><a class='toggle right' href='#' title="{$this->lang->words['toggle_cat']}">{$this->lang->words['toggle_cat']}</a>{$this->lang->words['recent_gallery_images']}</h3>
	<table class='ipb_table' summary="{$title}">
		<tr>
			<td>
				<div id='attach_wrap' class='rounded clearfix _sbcollapsable'>
					<ul>
					<foreach loop="gallery_images_hook:$rows as $r">
						<li class='<if test="nosidebar:|:IPSCookie::get('hide_sidebar') == '1' || !$this->templateVars['sidebar_enabled']">no_sidebar</if>'>{$r['_image']}</li>
					</foreach>
					</ul>
				</div>
			</td>
		</tr>
	</table>
</div>
<br style='clear:both;' />


See that in foreach loop? Its this:

<li class='<if test="nosidebar:|:IPSCookie::get('hide_sidebar') == '1' || !$this->templateVars['sidebar_enabled']">no_sidebar</if>'>{$r['_image']}</li>


I took that code from "boardIndexTemplate".

Now comes the tricky part, when you open the page you can see that this code above works because that li element now have class of "no_sidebar". If you open the sidebar, that li element still have that "no_sidebar" class. If you refresh the page while the sidebar is still open, on that next page load that same li element will not have class "no_sidebar".

I was saw this on IP.Board default skin, when you open the sidebar #categories element gets class of "no_sidebar" and when you close the sidebar, that class is removed.

Now i know i can write small piece of javascript(i only know jQuery), but i really want to use default IP.Board code.

$(function(){
	$("#close_sidebar").click(function(){
		$(".recent_gallery_images li").addClass("no_sidebar");
	});
	
	$("#open_sidebar").click(function(){
		$(".recent_gallery_images li").removeClass("no_sidebar");
	});
});


Or maybe someone can convert this to prototype for me. Any tip/advise is welcome!


Thanks.

Źródło: http://community.invisionpower.com/topic/317500-problem-with-testnosidebaripscookiegethide-sidebar/

Powered by SD.Agregator (http://www.invisionize.eu)
© SpannerDEV (http://www.spannerdev.pl)