365 Stories

flowing with the tides of life in 2010, an online journal
Browsing COMPUTER & TECHNOLOGY

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.

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.

Diliman Prep launches interactive digital planetarium

April23

Today was Open House Day at Diliman Prep. Though we had expected many more people, we did get quite a number of interested influential individuals, including dear friend Minnie Elizaga and Queenie Escalona, to attend and get interested in the programs and facilities of the school.

The highlight of the day was the opening of the first-ever  digital and interactive planetarium to the public.

Inside the 7-meter dome, our voices was surprisingly audible, as sound bounced off the curved walls. When the guy across us talked to his friends, it sounded as if he was right in front of a mike.  We could only assume that we sounded the same to them, so we had to make sure and whisper only.  The astronomer-guide had to stay a a specific spot in the center of the dome to make sure that every one in the audience heard her perfectly.

We entered as a 5-minute intro video was playing. Then the astronomer guide took over, and we were treated to various views of the day and night sky at precise dates and times. We previewed simulations of the day and night skies are precise moments such as daytime at 11:20 am today in Manila, sunset on April 23, 2010, the night sky in London and at the North Pole, and the view of the skies on an audience member’s birthdate. We “travelled” through Saturn rings, and observed its moons up close.

Essentials to making money online

April2

A very useful short article I received in my inbox today talks about the essentials of making money online. It could very well work for just about any project these days.  Am posting it so I can regularly refer to the pointers, and remind myself whenever i become defocused by too many other interesting business ventures.  All italicized texts are mine.

Here’s my take on making money online. You can take it, you can leave it, but rest assured, it works. This really doesn’t need much more than a page, because the purpose here is to get you focused. (See tip #2) Now, get ready for the one-page report that could change your life.

The Essentials

#1. Take Action.
The most important thing you can do ever is take action. One of the biggest problems people have in online marketing is a thing called “Information Overload” and that’s mostly saying “I’m taking in so much information that I’ll never have time to implement it.” And yep, you can learn a whole bunch, really really fast online, but guess what? You’ll never be able to implement it all. So here’s our next tip:

There are zillion opportunities for anyone to make money online, but online will fit any single person’s disposition, goals, willingness to work, time, resources. One needs to research, ask questions, get recommendations. Check out if these are scams, and if people have actually earned from them. But once you’ve narrowed these down to your best 5 options for online business, take action.

#2. Take it one thing at a time
Not only is it important to take action, you really really need to do one thing at a time, whether or not it’s the best way or not. This is really important. When you’re brainstorming, you can think about all the possibilities, but when working on implementation, FOCUS. Don’t get scattered. Focus.

And like all business, be prepared to work. Nothing comes from nothing. Allow for some gestation period. Work on the business everyday, setting aside regular hours, even if it’s only one hour a day. The regular hours though can mean those one when everyone else is asleep.

#3. Get used to a ton of email
I get hundreds of emails every day. How often do I unsubscribe? Hardly ever. Unless it’s super annoying and entirely useless stuff, you’re best off keeping on the email lists, so you’ll always know what’s going on, and what to promote. You can organize it, and all that, but stop worrying about unsubscribing. If you don’t have enough space, get a free gmail.com mail account.

Yes, this is true, especially if you decide on pay-to-read-email programs. They’re quite easy to do, but you may need to sort our email into folders.

#4. You’ll need some things
You need a website or a blog (like this one), a Paypal account, a Clickbank account, and a autoresponder if you’re going to be marketing online. That’s just the bare essentials. Practically any legitimate program can pay you by Paypal or Clickbank. If they can’t, well… Check it out. Don’t spend too much time though, because it’s probably not worth it.

I have both Paypal and Clickbank, and will need to study how to use an autoresponder. Soon.

#5. The customer is always right
There’s nowhere near enough information about this in internet marketing. Sometimes customers can be really annoying, but if you treat your customers right, they’ll spend money on you. It’s that  simple.

Works for any business.  It’s the golden rule.

#6 You’ll need to know some things
You need to learn how to code HTML, and use FTP properly. If you don’t learn those, it’s going to be really difficult to succeed online. Also, you need to be able to write something convincing. Most marketers call that copywriting. Stack the odds in favor of somebody wanting to buy with value, and words, and you’ll do great.

If you checked out the “feeling bold” tab when you write a Note on Facebook, then you have a basic understanding of html. Most online affiliate programs will give you your own affiliate link to use (copy and paste) on your website or blog, just like the ones below.

That’s it. Thanks for reading. Now, Take Action! You’ll be glad you did.

Sincerely,
-Zech Smith ArticleWritingAssistant.com Churn Out Articles FAST!

Have site, blog, twitter?
Monetize your visitors!
Click here to learn more

Ewen Chia’s 24-hr Internet Business
« 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