Перейти к содержимому

Фото
- - - - -

Помогите оптимизировать


  • Вы не можете создать новую тему
  • Please log in to reply
4 ответов в этой теме

#1 LiD

LiD
  • Постоялец
  • 456 сообщений

Отправлено 15 февраля 2011 - 18:15

Сам не программист - дизайнер. Вот код, из него понятно что хочу. Помогите пожалуйста.

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');
}

  • 0

#2 Setor

Setor
  • Постоялец
  • 1 890 сообщений
  • Откуда:Эстония, Таллин

Отправлено 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;
	}
}

  • 0

#3 LiD

LiD
  • Постоялец
  • 456 сообщений

Отправлено 16 февраля 2011 - 11:06

На foreach красным подсвечивает. Посмотри пожалуйста. А так - то что надо.
  • 0

#4 Setor

Setor
  • Постоялец
  • 1 890 сообщений
  • Откуда:Эстония, Таллин

Отправлено 16 февраля 2011 - 11:49

На foreach красным подсвечивает. Посмотри пожалуйста. А так - то что надо.

А ты сначала запусти... У меня ничего не подсвечивает :)

а, точку с запятой надо

$data = array(
       ...
);

  • 0

#5 LiD

LiD
  • Постоялец
  • 456 сообщений

Отправлено 16 февраля 2011 - 12:32

Спасибо большое!
  • 0