网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > WordPress
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   IP: 117.95.89.130
Old 2013-03-20, 02:55 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default WordPress制作中小企业网站的思路和注意事项

在看该文档之前需要对WordPress主题模板的层次架构有一定的了解。简单介绍如图:


WordPress主题模板的结构层次

一.WordPress搭建中小企业网站思路
WordPress是基于文章的博客程序,而企业或产品网站也是基于一篇篇的文章,所以用WordPress搭建企业网站是可行的。用WordPress建中小企业站模板的思路如下:

1) 大分类+子分类:

首先,根据需求明确企业网站的整体结构,需要几大类的内容,如分为1产品介绍,2技术中心,3关于我们,4 试用购买,这些内容可以放在网站的主菜单上。

然后,细化企业网站结构,既明确子分类,如:



由上图可以清晰的了解网站的结构,上图中(16)表示该文章分类的id号,因为WordPress本身有一个未分类和链接占用分类的1、2两个id号,我们只能从3开始,图中id为3、4、5、6的几个分类为大分类;而7、8、9、10为3的子分类,其他父子分类关系也如此。子分类可作为网站内页的side里的内容。值得一提的是,(post)表示文章,“关于公司”、“联系我们”、“合作伙伴”三个文章是直接属于大分类5,这个网站的“关于我们”内页side里既有分类又有文章,如何解决?下边会有介绍。现在整体的大思路应该很明确了就是 大分类+子分类。

2) 让每个大分类内页的side里显示子分类:

如图:




这是我们要的效果 , 因为我们每个大分类下面都要显示各自的子分类 , 所以在 sidebar.php 里的分类列表只写 <?php wp_list_cats(‘child_of=5′); ?> 已经不能满足我们的需求。因此需要写一个if判断语句:

这个if语句帮我们解决了在每个大分类下面调用其各自子分类。

Code:
<?php $post = $wp_query->post;
 
  if ( in_category(‘ 3 ‘)|in_category(‘7′)|in_category(‘ 8 ‘) |in_category(‘ 9 ‘)|in_category(‘ 10 ‘))    <! — 如果文章属于大分类3及其所有子分类7、8、9、10时–>
 
    { wp_list_cats(‘child_of= 3 ‘);}   <! — 则显示分类3的子分类–>
 
  elseif ( in_category(‘ 4 ‘) |in_category(‘ 11 ‘)|in_category(‘ 12 ‘) |in_category(‘ 13 ‘)|in_category(‘ 14 ‘)) 

    { wp_list_cats(‘child_of= 4 ‘);}
 
  elseif ( in_category( 5 ‘)| in_category(‘1 5 ‘)|in_category(‘1 6 ‘)) 

    { wp_list_cats(‘child_of= 5 ‘);}
 
  elseif (  in_category(‘ 6 ‘)) 

    { wp_list_cats(‘child_of= 6 ‘);}
 
?>
但上面我们所提到的“关于我们”的side里是“文章+子分类”的列表,所以以上代码也不能完全满足,需要在 { wp_list_cats(‘child_of= 5 ‘);} 里加入已发文章的静态链接。如下:

Code:
{ 

?>
 
<li><a href=”<?php bloginfo(‘url’); ?>/about/company/” title=”关于公司”>关于公司</a></li>
 
<li><a href=”<?php bloginfo(‘url’); ?>/about/contact/” title=”联系我们”>联系我们</a></li>
 
<li><a href=”<?php bloginfo(‘url’); ?>/about/partner/” title=”合作伙伴”>合作伙伴</a></li>
 
<?
 
wp_list_cats(‘child_of= 5 ‘);
 
}
现在side里“文章+子分类”的列表,我们很好的解决了。由此启发,当我们在点击各大分类下side列表不一定都用分类,因为如果是分类的话,右边调用的是 category .php, 显示分类页。如果每个大分类下都是这样显示分类列表的话,看起来还是很像blog,不像企业网站。所以我们的网站构架要改一下了,如图:



正如图中所示有两种方法实现:一是写一篇该子分类概述的文章,文章里有其他该子分类的链接,把概述文章的链接用刚才所述的方法写在sidebar.php里;另外一种是写一个子分类概述page页面把链接写在sidebar里。这里我们采取第一种方法。因为用page的话会导致页面过多不好管理,而且page的url地址为: http://域名/页面缩略名/ 的结构,这样就不好识别是哪个分类的内容了。改完的代码如下:
Code:
<ul >
 
      <?php $post = $wp_query->post;
 
if (in_category(‘ 3 ‘)|in_category(‘7′)|in_category(‘ 8 ‘) |in_category(‘ 9 ‘)|in_category(‘ 10 ‘)) 

        {
 
        ?>
 
        <li><a href=”<?php bloginfo(‘url’); ?>/products/products-all/production/” title=”产品概括”>产品概括</a></li> 

        <li><a href=”<?php bloginfo(‘url’); ?>/products/features/functions-and-features/” title=”功能特点”>功能特点</a></li> 

        <li><a href=”<?php bloginfo(‘url’); ?>/products/strength/strength/” title=”核心优势”>核心优势</a></li> 

        <li><a href=”<?php bloginfo(‘url’); ?>/products/application/report-appdeployment/” title=”部署与运用开发”>部署与运用开发</a></li> 

        <?
 
        }
 
        elseif (in_category(‘4′)|in_category(‘1 1 ‘)|in_category(‘1 2 ‘)|in_category(‘ 13 ‘)|in_category(‘ 14 ‘)) 

        { wp_list_cats(‘child_of=4′);}   / * 该分类是“技术中心”,需要它为子分类,就直接调用其子分类 */
 
        ?>
 
        elseif ( in_category(‘5′)|in_category(‘ 15 ‘)|in_category(‘1 6 ‘)) 

        { 

        ?>
 
        <li><a href=”<?php bloginfo(‘url’); ?>/about/company/” title=”关于公司”>关于公司</a></li>
 
        <li><a href=”<?php bloginfo(‘url’); ?>/about/contact/” title=”联系我们”>联系我们</a></li>
 
        <li><a href=”<?php bloginfo(‘url’); ?>/about/partner/” title=”合作伙伴”>合作伙伴</a></li>
 
        <li><a href=”<?php bloginfo(‘url’); ?> /about /news/” title=”企业新闻”>企业新闻</a></li>
 
        <li><a href=”<?php bloginfo(‘url’); ?> /about /cases/” title=”成功案例”>成功案例</a></li>
 
        <?
 
        }
 
        elseif ( in_category(‘6′)) 

        { 

        ?>
 
        <li><a href=”<?php bloginfo(‘url’); ?>/about/download/” title=”下载试用”>下载试用</a></li>
 
        <li><a href=”<?php bloginfo(‘url’); ?>/about/purchase/” title=”购买产品”>购买产品</a></li>
 
        <?
 
        }
 
</ul>
至此,sidebar里的子分类(文章)列表已经改完。

接着,需要在子分类上标上该大分类的名称,这一点我仍是采用了if语句将其写死。

Code:
<h3>
 
<?php
 
if ( in_category(‘ 3 ‘)|in_category(‘7′)|in_category(‘ 8 ‘) |in_category(‘ 9 ‘)|in_category(‘ 10 ‘) ) { ?>产品介绍<?php }
 
    elseif ( (in_category(‘4′)|in_category(‘1 1 ‘)|in_category(‘1 2 ‘)|in_category(‘ 13 ‘)|in_category(‘ 14 ‘) ) { ?>技术中心<?php }
 
    elseif (  in_category(‘5′)|in_category(‘ 15 ‘)|in_category(‘1 6 ‘) ) { ?>关于我们<?php }
 
    elseif ( in_category(‘6′)) { ?>试用购买<?php }
 
?>
 
</h3>
至此,sidebar里的title名称也写完了。sidebar里的子分类(文章)模块内容也全都完成,如若需要可在下面再写点热点链接之类的内容。

最后,single.php、category.php、 archive.php (企业网站它的用处不大)、index.php等都可以调用该sidebar.php了。

3) 菜单调用大分类

Sidebar做好了,下面就让菜单上显示调用的大分类,调用 <?php wp_list_cats(‘include=3,4,5,6′); ?> 这句函数即可。include=ID:是我们调用的大类,多个大类的ID号用英文“,”隔开。

4) 修改category.php

现在菜单上列出的是大分类调用,这样每个大分类下面就都会显示分类列表,但如果现在有的大分类不想显示分类列表,而显示该分类的第一篇文章,就需要来修改category.php文件了。思路和修改sidebar差不多。最初 category.php的结构应该如下:

Code:
<?php get_header(); ?>
 
<?php get_sidebar(); ?>
 
<div id= ” content ” >
 
  /*这里是调用分类的内容*/
 
</div>
 
<?php get_footer() ?>
现在因为需要点击大分类3、5、6时,页面上展示的是文章而非分类列表,所以在 <div id= ” content ” ></div>里添加一个if语句:


把以前的 /*这里是调用分类的内容*/ else{ ?><?php i... <?php }的<?php i...中。而需要在结构中添加的是大分类3、5、6中<?php q...这一块的内容,代码如下

Code:
<?php query_posts(‘ name=production ‘); ?>
 
<div class=”post” >
 
  <?php while (have_posts()) : the_post(); ?>
 
    <h2><a href=”<?php the_permalink()   ?>”   class=”homesidetext1″ title=”<?php the_title() ?>”> <?php the_title() ?> </a> </h2>
 
    <div class=”entry”>
 
      <?php  the_content(‘Read the rest of this entry &raquo;’);  ?>
 
    </div>
 
  <?php endwhile;?>
 
</div>
query_posts ()是获取文章,其内参数可用 ’ p=文章ID ’ 或 ’ name=文章缩略名 ’ 来调用想放在大分类下首页的文章;

<h2></h2>里是文章名称;

the_content(); 是调用文章内容。

这样就可以在菜单中列出的大分类上点击,出来想要的文章或分类列表了。

以上几点就是企业级网站全站用WordPress搭建的大致思路。

二.注意事项

1、 这样的主题模板要基于WordPress的数据库,因为在写side时用到了分类的id号。

2、 正是因为第一条,这样的WordPress主题模板没有通用的,只能因企业而异。

3、 永久链接最好用 /%category%/%postname%/ (分类+文章缩略名)的形式,这样url地址会看起来更有结构性,看起来也更像企业或产品网站

Last edited by topvip : 2013-03-20 at 03:03 PM
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 12:21 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.