unique.wonders. (ex_uniquewo) wrote in component_help,
unique.wonders.
ex_uniquewo
component_help

Additional Custom Sidebar Components

More documentation. Part 3 of 3.

This is not a new tutorial but the way things are done has been changed a little. As usual I'd love to know what you think.


Since this tutorial hasn't been made part of the official documentation, comments have been disabled.

Additional Custom Sidebar Components

Please make sure you've read the Getting Started Guide before reading this tutorial.

To have more information, reading Using print_free_text is also recommended.

Last updated: January 21, 2006, 18:19 GMT.

Modifications:

This tutorial will enable you to add one or several custom components. Think of it as several free text boxes, except that you can put whatever you want in those (images, text, links, etc.). These new boxes will stay grouped together. You can't have the profile then a custom box then the summary then another custom box.
You can decide to keep the default free text box or replace it with your custom components.

It will apply to all your pages/views.

Screencaps/Journals using this tutorial: component_help

Layer: Theme and User (How do I create a Theme Layer?)

Overridden function: function print_free_text (Page p)

Set commands mentioned in this tutorial:
set show_free_text = true;
set free_text_text = "Free Text Header";
set free_text = "Free Text Content";

Issues: None.

Notes: People who want to reorder their sidebar components have to use this tutorial.
People who want to display their custom components only on certain pages have to modify their code according to the last part of this tutorial.

Instructions:

Compulsory: enabling the free text component

You have to do this, whether you're going to use the default box or not. Otherwise, none of your custom components will appear.

If you use the Edit Customizations interface, go to: Components tab/ Enable Free Text drop down menu.
If you use a User layer, type: set show_free_text = true;

If you want to keep the default free text box go to this section then to this section.

If you don't want to keep it go to this section.


Using the default free text box and adding another custom box below it:

Copy/paste this portion of code in its entirety into your Theme Layer. Save and Compile. If you get any error, you did not paste it properly or you pasted it inside another portion of code.


###############################
# ADDITIONAL COMPONENTS #
# component_help/#
# overrides print_free_text(Page p) #
###############################


function print_free_text(Page p) {
var string header = "";
var string content = "";

### DEFAULT FREE TEXT COMPONENT ###

print_comp_header($*free_text_text);
"""$*free_text""";
print_comp_footer();

### CUSTOM COMPONENT ###

$header = "Custom Component Title";
$content = """Custom Component Content: You can have HTML here.""";

print_comp_header($header);
print $content;
print_comp_footer();

} ### END OF FUNCTION


Of course, you can reverse the order of the components. Make sure that you have the whole code for each component and that the code stays within the function.


Editing the default free text component

If you use the Edit Customizations interface, go to:
Text tab/ Free Text Component Title
Components tab/ Free Text Component

Note: You can't use HTML there.

If you use a User layer, type:
set free_text_text = "Free Text Header";
set free_text = "Free Text Content";



Only having a custom box and no default free text box:

Copy/paste this portion of code in its entirety into your Theme Layer. Save and Compile. If you get any error, you did not paste it properly or you pasted it inside another portion of code.


###############################
# ADDITIONAL COMPONENTS #
# component_help/#
# overrides print_free_text(Page p) #
###############################


function print_free_text(Page p) {
var string header = "";
var string content = "";

### CUSTOM COMPONENT ###

$header = "Custom Component Title";
$content = """Custom Component Content: You can have HTML here.""";

print_comp_header($header);
print $content;
print_comp_footer();

} ### END OF FUNCTION



Editing the custom additional component

"Custom Component Title" is where you put the title. It has to stay between the two quotes.

"Custom Component Content" is where you put the content. It has to stay between """and """;. You can use HTML here.


Adding another/other additional custom components
Simply copy/paste these lines of code before the closing curly brace } of the function.

### CUSTOM COMPONENT ###

$header = "Custom Component Title";
$content = """Custom Component Content: You can have HTML here.""";

print_comp_header($header);
print $content;
print_comp_footer();



Example:


###############################
# ADDITIONAL COMPONENTS #
# component_help/#
# overrides print_free_text(Page p) #
###############################


function print_free_text(Page p) {
var string header = "";
var string content = "";

### CUSTOM COMPONENT 1 ###

$header = "Custom Component Title 1";
$content = """Custom Component Content 1: You can have HTML here.""";

print_comp_header($header);
print $content;
print_comp_footer();

### CUSTOM COMPONENT 2 ###

$header = "Custom Component Title 2";
$content = """Custom Component Content 2: You can have HTML here.""";

print_comp_header($header);
print $content;
print_comp_footer();

} ### END OF FUNCTION



Save and compile. If you get an error, make sure you didn't accidentally delete a quote or a semi-colon.


Credit: This tutorial is a new version of this one written by xevinx.
Subscribe
Comments for this post were disabled by the author