SideBar Hiding Plugin

Creating and modifying plugins.
Tys
Regular
Posts: 36
Joined: Thu Feb 24, 2005 5:18 am

SideBar Hiding Plugin

Post by Tys »

Starting a new thread for this.

First question. As the SideBarItem, SideBarTitle and SideBarContent don't have id tags I need to locate them by the class attribute. To speed up the javascipt I would like to itterate through as few elements as possible. Can I make the following assumption about the tags these are going to be in?

SideBarItem in a div tag
SideBarTitle in an h3 tag
SideBarContent in a div tag
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: SideBar Hiding Plugin

Post by garvinhicking »

Can't you use document.getElementByClassname? Because it could be up to a template author to put stuff into a table or use a h2 instead of h3 item?

But basically you are right, all default-based templates will probably never change those tags.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Tys
Regular
Posts: 36
Joined: Thu Feb 24, 2005 5:18 am

Post by Tys »

document.getElementByClassname doesn't exsist, I got a solution that should work fine though on any elements.

Things are looking promising as the trickest part is now done.

A CVS account for the plugin repository would be nice, you can e-mail me at tys@tvg.ca if the offer is still open.

Also working a simple plugin to combine two hidden sidebar items into a single sidebar item (ie a random image from a gallery using a url plugin, above an RSS feed from the gallery as a single sidebar).

Thanks,
Tys
Tys
Regular
Posts: 36
Joined: Thu Feb 24, 2005 5:18 am

Post by Tys »

Version one done, feed back appreciated.

http://tvg.ca/serendipity_event_sidebarhider.tar.gz
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

I'm a bit limited on time right now, but you'll get your CVS account shortly and can contribute this. Only thing I would like to ask you to is to use SPACES instead of TABS for indenting, and to properly indent all of the plugin code.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Tys
Regular
Posts: 36
Joined: Thu Feb 24, 2005 5:18 am

Post by Tys »

Will do, just used to using tabs at work, here everyone has different taste on tab width which is configurable in most editors. Plus I find it much easier to move around code. But I understand you want to keep everything consistent.

As for indenting, do you mean the outputted html? Or just the code itself?
Tys
Regular
Posts: 36
Joined: Thu Feb 24, 2005 5:18 am

Post by Tys »

Committed to CVS.
Tys
Regular
Posts: 36
Joined: Thu Feb 24, 2005 5:18 am

Post by Tys »

Here is an image of the extra config settings. I've only tested them with my theme so hopefully it loads up other themes correctly as well. If you run into problems, or something doesn't look right, let me know.
Image
shorshe
Regular
Posts: 14
Joined: Fri Jan 23, 2004 5:37 pm

coool thing!!

Post by shorshe »

I was pondering about writing something like this myself. great idea! I tried your plugin and it does everythin it should do (except throwing some errors, which apparently don't affect the functionality)

I am dealing with very limited space on my site www.twinblog.de/test since I have to squeeze two blog's on one site and have users who still use 800x600 as their screen resolution (... yes they still life).
With that in mind, hiding the sidebar with your plugin is not possible since everything, that makes the layout the slightest amount wider is unfotunateley not possible.

Did you ever think about hiding the sidebar completeley?
An just pop it up as it is needed?

I was thinking about something like this:
http://www.spiegel.de/wissenschaft/mens ... 64,00.html

If you hover over the button: "RESORT WÄHLEN" right under the "SPIEGEL ONLINE" Logo you can see a menu popping up right above the content... wouldn't this be great?
(since i am very bad coder - if i can call me a coder at all - I'd like to convince you to... but don't feel pressed. Only a suggestion)

greetinx
Tys
Regular
Posts: 36
Joined: Thu Feb 24, 2005 5:18 am

Post by Tys »

Thanks for the feedback. Can you give anymore details on the errors, they might not affect anything but it would be nice to squash them none the less.

Yes hiding the whole sidebar would be nice addition. Unfortunately I'm leaving the country in a week for 8 months and am really short in time to implement anything like this. Hiding the whole sidebar wouldn't be a difficult change. However displaying the link to pop the sidebar down in such a way that it would be generic and look good across all themes is a bit trickier.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

shorshe, if you need a solution fast:

Anywhere on your site put this:

Code: Select all

<script type="text/javascript">
function toggleBar(id) {
  obj = document.getElementById('id')
  if (obj.style.display == 'none') {
    obj.style.display = 'block';
  } else {
    obj.style.display = 'none';
  }
}
</script>
<a href="#" onclick="javascript:toggleBar('serendipityRightSideBar')">Right</a>
<a href="#" onclick="javascript:toggleBar('serendipityLeftSideBar')">Left</a>
That piece of code should hide your left/right sidebar. You could put it anywhere inside of any Smarty .tpl file of your template (index.tpl, for example).

This is much more easier than only hiding certain elements, so basically this could be solved more cleanly in your template than with a plugin.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
shorshe
Regular
Posts: 14
Joined: Fri Jan 23, 2004 5:37 pm

Post by shorshe »

Tys wrote:Thanks for the feedback. Can you give anymore details on the errors, they might not affect anything but it would be nice to squash them none the less.
Ok: i get errors, if no plugins are installed in the left or right sidebar.
se here:
Image
Tys wrote: Yes hiding the whole sidebar would be nice addition. Unfortunately I'm leaving the country in a week for 8 months and am really short in time to implement anything like this. Hiding the whole sidebar wouldn't be a difficult change.
too bad...
but good luck and have a nice stay!
Tys wrote:However displaying the link to pop the sidebar down in such a way that it would be generic and look good across all themes is a bit trickier.
yes, indeed. (thinking of kubrick...)
shorshe
Regular
Posts: 14
Joined: Fri Jan 23, 2004 5:37 pm

Post by shorshe »

garvinhicking wrote: That piece of code should hide your left/right sidebar. You could put it anywhere inside of any Smarty .tpl file of your template (index.tpl, for example).
Thanks!
l'll try it NOW :)

-----edit---------

Code: Select all

Fatal error: Smarty error: [in /www/htdocs/twinblog//77/77blog/templates/default/index.tpl line 24]: syntax error: unrecognized tag 'obj' (Smarty_Compiler.class.php, line 580) in /www/htdocs/twinblog/77/77blog/bundled-libs/Smarty/libs/Smarty.class.php on line 1088
:(

i put it in index.tpl...
Last edited by shorshe on Tue Apr 26, 2005 8:34 pm, edited 1 time in total.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Shorshe, also make sure you're using the latest version of the hider plugin! It seems you are using an older version; the error you're reporting was fixed in a previous version by me.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
shorshe
Regular
Posts: 14
Joined: Fri Jan 23, 2004 5:37 pm

Post by shorshe »

garvinhicking wrote:Shorshe, also make sure you're using the latest version of the hider plugin! It seems you are using an older version; the error you're reporting was fixed in a previous version by me.
I use the newest version i can get from here:
http://cvs.sourceforge.net/viewcvs.py/p ... ebarhider/
(I just downloaded the files again to make shure).

still i can see these errors.
Post Reply