Thứ Ba, 8 tháng 7, 2014

Xóa block trong 1 trang (How to remove block into a page of magento)

Xóa block trong 1 trang
 (How to remove block into a page of magento/Adding A CSS Class To The Body tag)

ví dụ Trong trang cutomer muốn không hiển thị my cart / giỏ hàng thì làm như sau:
 Mở file customer.xml layout
bỏ đoạn code dưới vào

 <remove name="cart_sidebar"/>

 nếu muốn dùng chung cho tất cả các trang thuộc customer thì bỏ vào trong thẻ
<default>
  <remove name="cart_sidebar"/>
</default>

.....

Thêm tên class vào body trong magento (How to add class into body in magento)

Thêm tên class vào <body> trong magento (How to add class into body in magento)

Muốn thêm tên class vào body của 1 trang nào đó ví dụ trang customer.
mở file layout : customer.xml 
chèn vào đoạn code :


 <reference name="root">
            <action method="addBodyClass"><classname>customers-profile</classname></action>
  </reference>


trong đó  customers-profile: là tên class mới thêm vào <body>

Thứ Hai, 30 tháng 12, 2013

Phân trang trong wordpress

Phân trang

Dùng hàm paginate_links() có sẵn trong wordpress


 <ul>
            <?php
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            $args = array(
                'posts_per_page' => 1,
                'category_name' => 'cong-nghe',
                'paged' => $paged,
            );

            $the_query = new WP_Query($args);
            while ($the_query->have_posts()):$the_query->the_post();

                echo ' <li>';
                echo '  <div class="title"> ';
                the_title();
                echo '</div>';
                echo '   <div class="img">';
                the_post_thumbnail();
                echo '</div>';
                echo '  <div class="content">';
                echo get_the_content();
                echo '</div>';
                echo '</li>';

            endwhile;

            $big = 999999999; // need an unlikely integer
            echo paginate_links(array(
                'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
                'format' => '?paged=%#%',
                'current' => max(1, get_query_var('paged')),
                'total' => $the_query->max_num_pages));
            ?>


        </ul>

Chủ Nhật, 29 tháng 12, 2013

Hiển thị bài viết ngẫu nhiên trong wordpress

 Hiển thị bài viết ngẫu nhiên trong wordpress dùng thuộc thính 'orderby' => 'rand'
// hiển thị 5 bài viết ngẫu nhiên
 
 <?php
        global $post;
        $args = array('numberposts' => 5, 'category_name' => 'thiet-bi-ho-tro', 'orderby' => 'rand');
        $posts = get_posts($args);
        foreach ($posts as $post): setup_postdata($post);?>

// Echo nội dung
.......................
<?php endforeach ?>

Hiển thị nội dung của các trang và bài viết

<?php while ( have_posts() ) : the_post(); ?>
            <?php the_content(); ?>
        <?php endwhile;?>