if (ICL_LANGUAGE_CODE == 'et') { if ( is_page('120') || $post->post_parent == '120' ) { get_sidebar('sea'); } elseif ( is_page('93') || $post->post_parent == '93' ){ get_sidebar('production'); } elseif ( is_page('98') || $post->post_parent == '98' ){ get_sidebar('factoring'); } elseif ( is_page('123') || $post->post_parent == '123' ){ get_sidebar('logistics'); } elseif ( is_page('122') || $post->post_parent == '122' ){ get_sidebar('building'); } elseif ( is_page('121') || $post->post_parent == '121' ){ get_sidebar('storage'); } } elseif (ICL_LANGUAGE_CODE == 'ru') { if ( is_page('34') || $post->post_parent == '34' ) { get_sidebar('sea'); } elseif ( is_page('39') || $post->post_parent == '39' ){ get_sidebar('production'); } elseif ( is_page('37') || $post->post_parent == '37' ){ get_sidebar('factoring'); } elseif ( is_page('47') || $post->post_parent == '47' ){ get_sidebar('logistics'); } elseif ( is_page('45') || $post->post_parent == '45' ){ get_sidebar('building'); } elseif ( is_page('42') || $post->post_parent == '42' ){ get_sidebar('storage'); }
Помогите оптимизировать
Started By LiD, фев 15 2011 18:15
4 ответов в этой теме
#1
Отправлено 15 февраля 2011 - 18:15
Сам не программист - дизайнер. Вот код, из него понятно что хочу. Помогите пожалуйста.
#2
Отправлено 15 февраля 2011 - 20:29
что-то типа
$data = array( 'et' => array( 120 => 'sea', 93 => 'production', 98 => 'factoring', 123 => 'logistics', 122 => 'building', 121 => 'storage' ), 'ru' => array( 34 => 'sea', 39 => 'production', 37 => 'factoring', 47 => 'logistics', 45 => 'building', 42 => 'storage' ), ) foreach ( $data[ ICL_LANGUAGE_CODE ] as $id => $sidebar ) { $id = (string) $id; if ( is_page( $id ) || $post->post_parent == $id ) { get_sidebar( $sidebar ); break; } }