Wednesday, February 22, 2012

Sidebar everywhere + custom content

This is not an add-on. Until someone does a proper add-on or we have it in core here's my workaround.
I'm not posting anything original.
The main strategy comes from Floris Xenfans here
http://xenfans.com/threads/article-extending-on-the-xenforo-sidebar.1241/
This is beautifully written so even I understood! But my post here puts together the simplest steps for managing a sidebar for novice admins as the system works at present.

###########################
To add the standard XF sidebar
add the following code at the bottom of page templates.
For example add it to the bottom of sidebar_online_users
Code:
<xen:sidebar>
</xen:sidebar>
This gets you the standard sidebar block with your avatar at top
under that - who's online (staff, your follows, members)
under that Forum Statistics
under that Share this page.

To access the template to add the code
Admincp/ Appearances/ Templates
Copy the template name in the little box top of the bar.

#############################
Templates list to add the snippet.
sidebar_online_users --- only <xen:include template="nodemenu" />
forum_list ---- only <xen:include template="nodemenu" /> but add near top before stats
forum_view --- (selected forum page)
category_view --- (selected category page)
thread_view
thread_create
pagenode_container
search_form
search_form_post
conversation_view
conversation_add
help_index
help_wrapper
account_wrapper
account_preferences
account_alerts
news_feed
news_feed_page_global
account_likes / likes_summary –--- did not work on Likes Received but wrapper did it
watched_threads
account_personal details
pagenode_container
find_new_threads ---- only add <xen:include template="nodemenu" /> above the </sidebar>


If you can add any template names for standard pages to this list please do.
I'll update here from your post if I can. [No new updates yet]

Q!uick method - but limited:
Add the snippet to PAGE_CONTAINER
This means some of the above get it so you don't need to add to all.

################################################
To find the name of a templates to add the snippet of code
open the page in your XF forum
on your browser - View/ Page Source (Ctrl+ U)
In the html page that opens separately go down past
Code:
<body>
on the left
- use Ctrl+F or Edit/ Find to locate it.

Then look for
Code:
<div id="content" class="NAME">
NAME is the template name you want.
(Thanks to Brogan for this powerful basic help.)

##################################################
BUT I haven't found how to add the sidebar snippet to the What's New page
because View Source gives me
Code:
<div id="content" class="">
so I dunno what to do.

Anyone?

If you can help I'll add it in above with thanks.

###################################################
To add your own block to the sidebar 
###################################################
- so you only have one place to edit/ update it for all the pages where you add your sidebar:

First create your own template. Not as scary as it sounds!

Admincp/ Appearances/ Templates
Top right click button Create New Template
It needs a name you can remember connected to the block you'll add.
My custom block is a menu list of pages and forums - the basic top level node tree. So I called my template "nodemenu."
The name must be like a password: one word/or a sequence of letters and numbers. It can also use underscore_ or hyphen- but must have NO spaces.

Here is an idea of what I put in the content box.
Code:
<div class="section" align="center">
<div class="secondaryContent">
TABLE CONTAINING LIST OF LINKS
</div>
</div>
The two code lines at the top come from Floris. This makes your block look like other sidebar blocks. They MUST have the "divs" at the bottom, one for each line at the top.

In between you can put the stuff you want - your Content.
To make separate lines of plain text add
Code:
<br />
at the end of a line. Otherwise it'll display as one long line even if you use Return on the keyboard.
Use html - make a table - or link to a graphic.

Save your template.
Now instead of putting the code above for the standard XF sidebar in all the types of pages ...
add a line of code in the middle.

Code:
<xen:sidebar>
<xen:include template="NAME" />
</xen:sidebar>
NAME is the name of your own new template.
For example my template to insert a list of links to the node tree is called "nodemenu."
So my code for adding to pages is
Code:
<xen:sidebar>
<xen:include template="nodemenu" />
</xen:sidebar>
Go through all the pages on the list up top here in this post adding this to the bottom.
Once you've done it, all you have to do to change your menu block on all the pages, is edit the new template you made. So for example I need to edit my "nodemenu" template.

I know this is very simple and nothing original to me. I think it's useful for novice admins to have a collection of bits like this in one place with all the steps spelled out thoroughly.

No comments:

Post a Comment