365 Stories

flowing with the tides of life in 2010, an online journal
Browsing EDUCATION & LEARNING

Custom sidebar blues finally dispelled

August8

For close to 3 months, I’ve been agonizing about creating custom sidebars for specific pages on the Diliman Prep website.

After long hours of searching for similar situations, diverted attention to the inspiring design pages of Smashing Magazine, passing through the learning curve of self-taught on-the-job training for basic php coding, too many sleepless nights and several dreams of solutions, I finally did it.

All the blogs and documents I was able to refer to tackled my concern in portions, perhaps because they too were writing only about their own concerns. Fact is, all of them were IT developers, while I have been introduced to php only when I decided to change certain portions of the wordpress themes I was using for my websites. I wish I can link to those sites that helped me understand the process, and will do so when I run across them again.

I desperately need to document the process that lead to the solution, if only so I could easily refer to this blog again whenever I wish to create custom sidebars to this blog site (which obviously needs the work) and to the other sites I will be creating.

Now if a reader finds this record useful for the php novice, that will be an exceptional bonus.

Creating Custom Sidebars in WordPress

Objective: Create custom right sidebars for different departments and concerns featured on the website. The left sidebar and the horizontal menu on top will be retained for overall site navigation.

Rationale: The same sidebar for all pages will eventually make the eye go blind on the items, notices, lists, that are on that sidebar, so that even if the items are quite important for the school to share, the reader will not consider it as such. He becomes blind to the item, unless it’s a list that need to be referred to every so often, like a category list or a topic list. But fixed images, and ads tend to be disregarded by the eye.

Also, the school also has myriad details that could be useful to the reader of certain pages, but these information would otherwise be hidden under and behind other material on the side. For example, readers interested in the Athletics Department would more likely be interested on who the coaches are and how to contact them directly. If this information was on the custom sidebar, the site is able to immediate meet the need of the reader.

Step 1: REGISTER new widgetizable sidebars  in the functions.php  file of the theme

Since my theme already has two functioning sidebars, the functions.php file has already been automatically created by WordPress. Here’s how my functions.php file looked like without the additional custom sidebars.

<?php
if(function_exists(‘register_sidebar’)) {

register_sidebar(array(
‘name’ => __(‘Left Sidebar‘),
‘before_widget’ => ‘<div id=”%1$s”>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h3>’,
‘after_title’ => ‘</h3>’
));

register_sidebar(array(
‘name’ => __(‘Right Sidebar‘),
‘before_widget’ => ‘<div id=”%1$s”>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h3>’,
‘after_title’ => ‘</h3>’
));

} ?>

I then registered an additional sidebar that I indent to use for the pages on the Athletics Department. The number 3 in the ‘Athletics 3′ is my reference to the actual number of the sidebar, which I will need later. I actually have a total of 15 custom sidebars. (The left sidebar is number 1. The main right sidebar is number 2.)

register_sidebar(array(
‘name’ => __(‘Athletics 3‘),
‘before_widget’ => ‘<div id=”%1$s”>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h2>’,
‘after_title’ => ‘</h2>’
));

On the Appearance Widgets menu, I can now see the third sidebar named Athletics 3.

Step 2: Create a duplicate copy of the right_sidebar.php and a designate name that can easily be associated with the new sidebar.

I named my new custom sidebar right_sidebar-athletics.php and made sure that the call to the sidebar would refer to the custom sidebar for Athletics that I just made. Here is where the number 3 in the sidebar name becomes convenient.

<?php if (function_exists(‘dynamic_sidebar’) && dynamic_sidebar(3)) {  } ?>

[I was able to make the file copies using my freely downloaded copy of FileZilla, by selecting a file on my live server, right click Open/Edit. I changed the sidebar number to (3) and saved it with a new filename as above.]

Step 3: Edit the call for the new sidebar in the appropriate theme template file.

In my case, I opened the page.php file because I wanted to reflect custom sidebars on specific pages, to give the instruction to use the right_sidebar-athletics.php file in place of the standard right sidebar whenever the the active page is that of Athletics. The page ID for the Athletics page is 513, so I entered that in the call code.

<?php
if  (is_page(’513′))  {
include(TEMPLATEPATH . ‘/right_sidebar-athletics.php‘);
} else {
get_sidebar();
}
?>

Step 4: Add content to the custom sidebar.

Finally, on the Appearance Widgets menu, I opened the new sidebar that I named Athletics 3, and added my own html text and widgets (could be anything you want).

Then I shifted back to the window/tab of the website and clicked on the link to the Athletics page. YES, FINALLY, IT’S DONE. I had the new custom right sidebar up for the Athletics pagee, and retained the original right bar for all the other pages.

Within 15 minutes, I had gone through the whole process for 14 other website sections with pages that would benefit from custom sidebars.

But though I had finally solved the mystery of the custom right sidebar, the same did not work for the subpages.

Step 5: Generate a new conditional tag to check for subpages and apply the appropriate custom right sidebar.

I had seen the instructions for this the first time I searched the net, but could not make them work because the first 4 steps above were not yet in place. Now was the time to do so.  The solution turned out to be quite easy after the months of understanding php on my own.

I added a new function in the functions.php file to enable WordPress to check and identify the subpages.

function is_tree($pid) {      // $pid = The ID of the parent page
global $post;         // load details about this page
$anc = get_post_ancestors( $post->ID );
foreach($anc as $ancestor) {
if(is_page() && $ancestor == $pid) {
return true;
}
}
if(is_page()&&(is_page($pid)))
return true;   // we’re at the page or its subpage
else
return false;  // we’re elsewhere
};

“Add Snippet 4 to your functions.php file, and call is_tree('id') to see if the current page is the page, or is a sub page of the page. In Snippet 3, is_tree('2') would replace “is_page('about') || $post->post_parent == '2'” inside the first if tag.”   Refer to Snippet 4 in WordPress Codex on Conditional Tags.

And I replaced the conditional tag

<?php
if  (is_page(’513′))  {
include(TEMPLATEPATH . ‘/right_sidebar-athletics.php’);
} else {
get_sidebar();
}
?>

to this call in the pages.php file

<?php
if  (is_tree(’513′))  {
include(TEMPLATEPATH . ‘/right_sidebar-athletics.php’);
} else {
get_sidebar();
}
?>

After confirming that the codes resulted in the effect I wanted, I adjusted all the calls for the custom sidebars for the other web sections.

P.S.

I could actually have solved this problem much earlier, if only I had changed some of my work habits.  I finally realized that I had spent the worst hours of my day–when I was practically tired and ready to sleep– to study the possible solutions to custom sidebars. I had not given it the due attention during my more productive hours, thinking that I could extend my prime time to the hilt.

Sometime, the other night, I resolved to attend to the task at last 3 hours earlier than usual. Within an hour-and-a-half, I had solve the problem. Twas an exhilarating eureka-moment with the attendant heart-pounding and raised-arms as I refreshed the page and saw the new sidebar.

My next project: Using thumbnails of my posts photo in the excerpt on the Home page.

Lesson learned: Never overestimate my mental acuity when fatigue and sleepiness start to creep in. Sleep is necessary to revitalize the body and produce the new brain cells, that will enable me to challenge myself for the next project. Good night y’all.

Rediscovering oneself through writing

May19

Children never cease to amaze me. They never run out of creative ideas. The younger ones seem to be much more spontaneous; the older ones often pick up topics and cull from situations in their conscious environment. Either way, imagination obviously is the basis of their stories, poems, and illustrations, often instantaneously and spontaneously manifested within seconds of  the slightest stimulation — a statement, an idea, a comment, a memory.

The eight sessions I spent with 17 children aged 6 to 13 this summer were exceptionally revealing–about the kids and about myself. Frankly, I had thought I had the program wrapped up tightly when Ms. Luz Estudillo and I talked about conducting a Young Writers’ Workshop at the Headway School for Giftedness.

Little did I realize that these precocious bright kids can be more challenging to my usual flexibility and adaptability. Most were attentive, and patiently listened to explanations. Some often got ahead of the short lectures with their series of questions. Others couldn’t seem to refrain from their excited sharing and expressions. But all had more than enough to say during the many passionate discussions, and writing sessions. (Several times, I had tried to feign anger and frustration, in an attempt to get a common response — silence. Worked for a few seconds, then off we were again, almost everyone talking at the same time.)

I had tapped into countless experiences workshops with high school and college students, as well as professionals, yet kept totally open to approaches and content. The lesson plans were often mere rough outlines, open to changes and adjustments on the spot, and usually depending on the children’s reactions.

In our few weeks together, we learned to imagine, create, listen and report the facts, and express our opinions in the best words we could muster. This compilation of their works proves the deep well from which they pull their thoughts and ideas.

My role, I knew, was not to correct their grammar and spelling (I leave that to their regular teachers). But we did spent some time to help each other reading and checking each other’s work. The workshop however was meant to bolster each child’s natural ability to imagine and create, and translate their thoughts and ideas into written words, sentences, paragraphs.

We found though, that at the end, we were not only learning to write. More importantly, we were rediscovering ourselves, and learning a few other lessons in life: team work and cooperation; acceptance of our imperfection; trusting friends to help us with point we may have overlooked; respect for each others’ thoughts and ideas; listen when someone else is talking and they will listen when you are talking,

Perhaps, in a few months or years, we can look at this compilation of works, and tell ourselves “I should have included this or that point”, or “written my paragraph this way.” (I know I will say this to myself about this piece).

But then that’s the essence of learning to write – organizing and putting our thoughts on paper, editing ourselves, allowing others to edit our work when needed, and finally letting go of the final material for publishing. Anyway, we have infinite opportunities to imagine, and experiences to write about. Continue to write. It’s the only way to perfect our craft.

had tapped into countless experiences workshops with high school and college students, as well as professionals, yet kept totally open to approaches and content. The lesson plans were often mere rough outlines, open to changes and adjustments on the spot, and usually depending on the children’s reactions.

Living is learning something new every day

May6

During the past weeks, I couldn’t help but be engrossed with astronomy and the stars and the far reaches of the universe. Diliman Preparatory School’s mobile digital planetarium had been released by customs of several weeks. Now local astronomers were busy studying the capabilities of the accompanying software and hardware, which made the planetarium the first and only fully interactive planetarium in the Philippines.

After attending my fifth viewing this morning, I still learned many more bits of information about our night sky, and astronomy as a field.

For instance, a Filipino amateur astronomer, Christopher Go from Cebu, discovered the  second of Jupiter’s red spots in early 2006. Other astronomers worldwide confirmed the discovery, actually the change of the spot’s color from white to red, and was eventually dubbed Red Spot Jr., or Red Jr. The history and developments on Jupiter’s Red Spot Jr. are recorded on http://redspotjr.christone.net/.

Some days ago, I had searched the net for the Digitalis website, and excitedly downloaded a sample astronomy simulation software Nightshade, and had fun experimenting with images of the sky on my PC. Coupled with the free sample astronomy curriculum, one can easily get engrossed in self study about outer space. Stellarium is another planetarium program, in Open Source, that can also be used on regular computers for astronomy classes.

Of course, these are too far behind the technology of the Digitalis software that  powers the interactive presentations at Diliman Prep’s mobile interactive planetarium.

The local astronomers said enough about how they were not only getting used to the many varied features of the Digitalis program, but will soon be inputting the localized images that will enable more Filipinos to relate and understand astronomy.

We found out this morning that while many of us are more familiar with the formation and names of constellations based on the Roman gods, various cultures had looked at the same skies for millenia, and had interpreted and formed their own images from the heavenly bodies based on their day to day life. We were showed simpler formations in the shape of a house, or standing person, or a box among the cultures of Indonesia, China, Polynesia or the American Indians.

We also learned how constellations can be recognized as asterisms or as illustrations, and that these can vary greatly from culture to culture, as they recognized shapes among the heavenly bodies from their day-to-day lives.

Filipino folk lore had referred to Orion’s belt of three stars as Tatlong Maria — Mariang Mambabalut, Mariang Magmamane, and Mariang Magtuturon (or whatever). The astronomers hinted that they will be inputting more localized interest topics into the presentations to include perhaps the local astronomers and imagers who have discovered several of the heavenly bodies, and have been cooperating with the international community to leap and bound farther into the deepest recesses of the universe.

We also learned how constellations can be recognized as asterisms or as illlustrations, and had downloaded to my laptop,

I can’t wait till my next opportunity to view yet another presented in the mobile digital planetarium, for I’m sure that even with my own revitalized interest and research  on the universe, I will still acquire a few more its of information about the nature of our universe.

I am sure that my interest in astronomy now is not a coincidence. And beyond the willingness to ride the waves through this most interesting phase of my life, I have awakened a keen desire to remember knowledge that I know we all already possess. For we are star people, ever connected to the universe that we continue to understand with our limited minds. Deep inside though we know that every bit of new information brings us closer to a better understanding of ourselves.

Astronomy 101 at Diliman Prep’s mobile planetarium

April30

In my whole life, I remember visiting a planetarium only three times, twice at the Pag-asa Planetarium on Agham Road in Quezon City as part of school field trips, and once at the Griffith Observatory and Museum in Los Angeles. These planetariums were huge simulations of the night sky, brightened by an illuminating bulb to simulate day time.

At the Pag-asa Planetarium, the positions of planets,  stars, galaxies  and nebulae were fixed, but all rotated together as the holed projector cover they were projected through was moved.

At the Griffith Observatory which I visited with two of my siblings and their families in 2008, we watched a 20-minute film documentary — about the history of the universe, a simulated trip to the Sun, the Moon, and Mars, and highlights of space adventure –  that had left us feeling awed and a little more knowledgeable than before. The space museum that supported the planetarium was breath-taking, which was partially interactive.  We particularly loved the weighing scales calibrated to show how we would weigh on the moon, and on other planets.

Today, however, my daughter and I experienced a preview (three in fact) of the vast infinitely deep outer space  at a 7-meter-diameter Mobile Interactive Planetarium set up at the gym of the Diliman Preparatory School along Commonwealth Avenue in Quezon City.

Our view from Earth

Real live astronomers Bamm Gabriana and Rochelle Derilo asked us to note the local time on a digital clock near the horizon, toured us through tonight’s night sky,  the rising sun tomorrow, traveling up across the sky and down again towards the western horizon and sunset. They explained that the earth’s atmosphere causes the day and night illumination of the sky as the light from the sun is reflected through it.

I can only assume how this happens but I should have asked the astronomers after the preview — Why and how does the atmosphere create the day and night on planet earth? Does this happen on all planets? So many whys and hows? All the while I thought it was as simple as the earth facing the sun half of the time.

At one point, Bamm advanced the sky view to May 5, 2010.  Some of us shrieked in delight as we caught meteors streaking through the night sky. He explained that on May 5 and 6, the Eta Aquarids will peak and be radiant in the constellation Aquarius,  best viewed in the east after midnight.

Closing in at warp speed

Two planets can be seen from Metro Manila tonight — Saturn and Mars. We closed in on Mars and noted its polar cap composed of  frozen carbon dioxide. We flew in to Saturn at warp-speed and checked its thousand rings of debris and empty space,  and 7 of its 56 satellites.

Back on earth again, with a click on the remote control pointed upward, Bamm revealed the imaginary line connections that form and give the constellations their names.  We viewed the night sky with superimposed views of the constellations and their boundaries.

Turns out that on a totally dark night, the naked eye can see some 6000 satellites, planets, stars, galaxies, nebulae (3,000 or so from each hemisphere), as opposed to the claim that one can see a million stars. But beyond some of these luminous specks in the sky are galaxies and nebulae that contain millions of galaxies with billions of stars.

With another flick of a button, we see the artistic rendition of the constellations and their imaginary boundaries. More ohhs and ahhs.

AstroLOGers, not astroNOMers, would refer to aspects of our birth charts based on the position of the sun, moon and planets within these constellations at the time of our birth. AstroNOMer Bamm noted that reading palms does not make one an astroNOMer.

Orion Constellation

We closed in on the constellation Orion, the hunter of Greek mythology.  At his shoulder is the bright North Star. We recognize Orion’s Belt of three stars — Alnitak, Alnilam, and Mintaka.  Local folk lore refers to these stars as Tatlong Maria.

Below Orion’s Belt is a vertical group of bright objects forming the Sword of Orion. One of these objects is the Orion Nebula some 1,450 light years away, where so many new stars are being born. Again we flew in closer to the nebula and were aghast at the thought of millions of stars staring back at us.

Hubble’s Deep Field

Finally, Bamm zeroed in on an area of space that scientists call the Hubble Deep Field, a tiny area which the Hubble Telescope focused on for a long time, and came up with images of galaxies and stars far beyond our vision.

January 15, 1996: One peek into a small part of the sky, one giant leap back in time. The Hubble telescope has provided mankind’s deepest, most detailed visible view of the universe.

Representing a narrow “keyhole” view stretching to the visible horizon of the universe, the Hubble Deep Field image covers a speck of the sky only about the width of a dime 75 feet away. Though the field is a very small sample of the heavens, it is considered representative of the typical distribution of galaxies in space, because the universe, statistically, looks largely the same in all directions. Gazing into this small field, Hubble uncovered a bewildering assortment of at least 1,500 galaxies at various stages of evolution.”

(Sourced from Hubblesite)

Watch a video about the Hubble Deep Field

I couldn’t resist asking: If  the most sophisticated man-made telescope was able to record how far reaches of the universe looked like billions of years go, do we have an idea of how big the universe is?

Astronomer Bamm Gabriana casually replied: “We can only speculate, but not actually say the actual size of the universe. We use the only fixed measurement that we have right now — the speed of light at, 299,000 per second — and are able to compute the approximate distance of many of the farthest objects we see. Beyond that, we can only assume.

Piqued my imagination again

The 20-minute re-introduction to astronomy inside the Diliman Prep School Mobile Interactive Planetarium pique my interest in astronomy again. It inspired me to record this most memorable experience here on my 365 Stories blog, with some online research on the bits of facts I learned, and photos of space (in place of the blurry ones that I tried to take with my smartphone) to link my story to.

“Astronomy is the starting point  for most youngsters to get interested in Math, Physics, Chemistry, the earth sciences and the environment,” says  Bernard Llaguno, a professor at the Philippine Science High School who heard about the mobile planetarium’s  launch and wanted to see how his students can experience it too.

Outside the planetarium in the Diliman Prep gym, almost a hundred other people waited their turn to enter the planetarium. But they did not have to wait too long as time went by more rapidly with the fantastic collection of NASA space photographs taken through the Hubble telescope and several space missions, and a hands-on meteorite exhibition.

Many posed for photos with Diliman Prep president, former Senator Nikki Coseteng, or some of the astronomers, with one of two state-of-the-art telescopes (purchased by the school in January this year, in time for the annular solar eclipse on January 15 2010. I believe I wrote a blog item on this not too long ago.)

The planetarium will be on tour to various schools nationwide, starting July this year, so that more Filipinos can become interested in astronomy and the various sciences.  As Nikki Coseteng explains, more creative and scientific minds can help us Filipinos meet the growing challenges of our life on this earth, including climate change.

Lesson 2 on Creative Writing

April28

We pursued our class on the Young Writers’ Workshop for Headway School for the Gifted with another writing exercise. But before that  the children submitted their articles on the previous session’s assignment.

I had decided to read their assignments at home, and proceeded discuss the parts of a short story in more detail — character, setting, and plot. Using a central circle drawn on paper, connected to several other circles, each student gave his/her character a name and their descriptions, likes, hobbies, disposition, mood, and many other characteristics to differentiate the character from others.

From the characterization, they each decided on a setting, describing colors, surroundings, mood, and scents, objects and people in the area, the situation. Pretty soon each one was developing a plot for the story. I asked them to take this activity home, computerize it, add illustrations or  photos, and submit at the next session.

Back home, I checked their articles and was truly surprised at the diversity and creative imagination of the children. They were not only extremely expressive, but also picturesque with their descriptions. A few had incorporated dialoque in their stories.

I realized that I wasn’t dealing with ordinary school children, but with late-teeners with 6 to 13-year-old bodies.

« Older Entries

365 STORIES CAN BE VIEWED
FROM MOST MOBILE DEVICES.

Subscribe

DOWNLOADABLE E-BOOKS

BABIES CAN (and did!) READ

FIVE RITUALS: SECRET TO
THE FOUNTAIN OF YOUTH

RUN YOUR CAR ON WATER

INSIDER SECRETS TO CHEAP FLIGHTS

OFFICIAL SECRET RESTAURANT RECIPES

PANIC AWAY - END ANXIETY & PANIC ATTACKS

SECRETS TO DOG TRAINING (SIT.STAY.FETCH)

GUIDE TO CREATING SPA PRODUCTS

500 SCRAPBOOKING SKETCHES

THE DIET SOLUTION PROGRAM

Hi, I’m Vikky, and I’ve finally made a New Year’s resolution that’s exciting and motivating enough to follow-through and resolve to attain.  Read about it in my first post and Why 365 stories?. This blog is just what it says — 365 Stories — one story (or more) everyday for the 365 days of 2010.

Discover CHIA seed, the ancient survival food of the Aztecs

My Sulit Homepage


Sign up for PayPal and start accepting credit card payments instantly.

    Buy and Sell Philippines    

        WordPress Themes by WPZOOM

    Adzelerate    

Links

Advertise On This Blog

Freelance Jobs