韩国的 整形 大夫

wordpress:dynamic sub-page navigation

In wordpress usage on 7월 16, 2009 at 11:04 오후

WordPress: Dynamic Sub-Page Navigation

Filed as Features, Guides on July 26, 2007 11:44 am

The more and more I study the WordPress architecture, the more and more convinced I become that WordPress is a great choice for use as a feature rich Content Management System (CMS). Basically, WordPress can be used, not only as a blog platform, but as software to manage the content of any website, with or without a blog. Because WP added the ability to use “Pages” to hold relatively static content, and because WP includes functions to call and display the content of those pages just about any way you can think of, all it takes is a good WordPress theme to get the job done.

But where WordPress lacks as a CMS is the ability to further exploit the sub-page system. Not so much in their use, but in their application to the actual website design.

However, this plugin did wonders for people looking to take advantage of the hierarchal structure of pages and sub-pages by allowing only the “parent” pages to be displayed on the homepage. And if a “parent” page has children, and that page’s link is clicked, then the child pages will “fold” down, displaying “deeper” options (much like the features of the more mainline CMS out there).

But There’s a Problem

I’m not here to just give props to a cool plugin. You see, I had a client who wanted the original “parent” list across the top of the page (just under the header image) and when one of the “parent” page links was clicked, he wanted the “sub-pages” to display as a list in the sidebar. As far as I could tell, there was no way to do that with the Fold Page List plugin. So, I went searching. I promise, if I could find the original website I got this from, I’d give a link. As it turns out, I can’t find it. Sorry :-)

First thing to do is just list your pages. Be sure to make it top-level only!

<?php wp_list_pages(‘title_li=&depth=1′); ?>

Then, I used the code I found (with a few modifications, I’m sure):

<?php
global $wp_query;

if( empty($wp_query->post->post_parent) ) {
$parent = $wp_query->post->ID;
} else {
$parent = $wp_query->post->post_parent;
} ?>
<?php if(wp_list_pages(“title_li=&child_of=$parent&echo=0″ )): ?>
<div id=”submenu”>
<ul>
<?php wp_list_pages(“title_li=&child_of=$parent” ); ?>
</ul>
</div>
<?php endif; ?>

Without getting too technical, I’ll explain roughly what all that means.

if( empty($wp_query->post->post_parent) ) {
$parent = $wp_query->post->ID;
} else {
$parent = $wp_query->post->post_parent;
}

This code checks to see if the current page (the active page) as a parent. If it does NOT have a parent … it assigns the current page ID as the “parent”. If it DOES have a parent, it assigns the parent ID as the “parent”. The reason this is necessary is for top-level parents. If we simply used the parent ID to assign the “parent”, then if a top-level parent was active, the “parent” variable would be empty and we wouldn’t get our sub-page list.

<?php if(wp_list_pages(“title_li=&child_of=$parent&echo=0″ )): ?>
<div id=”submenu”>
<ul>
<?php wp_list_pages(“title_li=&child_of=$parent” ); ?>
</ul>
</div>
<?php endif; ?>

This last part is pretty simple. All it checks for is IF there are any sub-pages (in a very rudimentary way). If it does have sub-pages, then it lists them (along with a title and some div wrappers for style).

One Limitation

I didn’t spend too much time doing research on this, but as far as I can tell, this only works 2 levels deep (top-level and 2nd level). If you have 3 levels of sub-pages, this won’t work (or at least won’t work like it’s supposed to). Sorry, but all I needed was 2 levels, so that’s all I developed it for :-)

Download the Source

Click Here to download the source for this script

So, if you are looking for a quick and dirty way to use WordPress as a CMS, this little bit of code can go a long way. I’ve used it several times since the time I developed it, and I plan on using it many times in the future!

Next week, I’m writing a tutorial on how to do the same thing we did here, but with categories and sub-categories. Don’t miss it!

UI개발자를 위한 북마크

In Uncategorized on 7월 16, 2009 at 10:51 오후

UI 개발자를 위한 북마크

NARADESIGN

목차

[숨기기]

뉴스

드림위버

모바일

블로그

웹 표준

웹 접근성

IT Trends

User Experience

블로그 허브

사용자 맞춤형 웹 서비스

사전

웹 디자인

웹 브라우저

웹 브라우저들

웹 브라우저 시뮬레이터

  • Browsershots – http://browsershots.org/ 현존하는 10 여종의 웹 브라우저에 대한 Simulator 테스트. 브라우저 선택 옵션에 모두 체크해도 한번에 4~5개 정도 밖에 Simulation 되지 않으며 시간이 오래 걸리고 추가 테스트를 진행 하는 경우 기존의 스크린샷이 사라지므로 스크린샷은 PC에 저장하는 것을 권함.
  • Internet Explorer Collection – http://finalbuilds.edskes.net/iecollection.htm 모든 버전의 IE를 스텐드얼론 형식으로 사용할 수 있다. 개발자용 IE툴바를 사용할 수 있는 것이 장점이나 정식으로 설치된 IE 브라우저에 다양한 버그를 유발하는 단점이 있어 권장하지 않음.
  • iPhone/iPod Touch Simulator – http://testiphone.com/
  • Multiful IE – http://tredosoft.com/Multiple_IE IE 3~6 브라우저에 대한 렌더링 툴.
  • Opera Mini Simulator – http://www.operamini.com/demo/ Mobile 전용 웹 브라우저 Opera Mini 의 렌더링 테스트.
  • Safari Simulator(BrowsrCamp) – http://www.browsrcamp.com/ Mac OS 전용 웹 브라우저 Safari 의 렌더링 테스트.
  • Xenocode Browser Sandbox – http://www.xenocode.com/browsers/ IE 6~8, FF 2~3, SF, OP, CR 브라우저를 실행파일을 이용하여 설치 없이 테스트 할 수 있다.

웹 브라우저 테스트

웹 브라우저 호환성 문제

웹 브라우저 확장

웹 사용성

웹 성능 분석

웹 어플리케이션

웹 이미지 검색

사진

아이콘

웹 접근성

지침

웹 표준

통계

CSS

CSS Framework

CSS Reference

CSS Standards

CSS Vendor Extensions

Flash

Fonts

HTML/XHTML

Javascript

User Interface 개발

游泳练习 Gtrack

In 游泳练习 on 7월 16, 2009 at 2:01 오전

 

http://www.youtube.com/watch?v=kjgN4aQyeSc

팔로우

Get every new post delivered to your Inbox.