27 mar 2012

Losowe wybranie postów z wybranych kategorii

Losowe wybranie postów z wybranych kategorii, opcja rand

<?php $recent = new WP_Query("cat=1,2,3&showposts=10&orderby=rand"); while($recent->have_posts()) :
$recent->the_post();?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<?php endwhile; ?>
27 mar 2012

Odczyt wartość pola option na podstawie selectedIndex

Odczyt wartość pola option na podstawie selectedIndex i wstawienie do pola hidden

<select name="stanowisko_sel" onchange="this.form.stanowisko.value = 
this.options[this.selectedIndex].text">
  <option value="1">Kierowca</option>
  <option value="1">Budowlaniec</option>
</select>
<input maxlength="50" name="stanowisko" size="50" type="hidden" />
20 mar 2012

Zmiana wartości opcji selecta

Zmiana wartości opcji selecta

$('#right table td input[name=imie]').parent().parent().parent().css({'display':'none'});
$('#right table .teh').parent().parent().parent().parent().css({'display':'none'});
$('#right table td select[name=stanowisko] option:eq(0)').replaceWith("Zamiana wartości text");
$('#right table td select[name=stanowisko]').parent().prev().html('Zmiana tytułu labela nad selectem taki');
$('#right table td select[name=stanowisko]').val('0');
20 mar 2012

Dynamiczne utworzenie nazwy zmiennej

Utworzenie zmiennej

!{assign var=tmp_work value="imp_1_dzien_"|cat:$w_data[ii].work_day|cat:"_pozycja_"|cat:$w_data[ii].work_id}!
!{assign var=check_work value="check_"|cat:$tmp_work}!
!{if $get_data.$check_work}! checked!{/if}!

Wykorzystanie w pętli

!{section name=ii loop=$w_data}!
<tr>
!{assign var=tmp_work value="imp_1_dzien_"|cat:$w_data[ii].work_day|cat:"_pozycja_"|cat:$w_data[ii].work_id}! !{assign var=check_work value="check_"|cat:$tmp_work}! </td>
<td><input type="checkbox" name="check_!{$tmp_work}!" value="1"!{if $get_data.$check_work}! checked!{/if}!/></td> <td><label for="!{$tmp_work_name}!">!{$w_data[ii].work_day}!</span>dzień</strong> !{$w_data[ii].work_date|date_format:"%Y-%m-%d"}!</td>
</tr>
!{/section}!