CCK+Views 创建相册的实现总结

前段时间想用CCK+ImageAPI+ImageCache+ImageField 创建相册。具体步骤:
新建内容类型photos,用CCK增加Image类型字段,字段名称为field_photos,这样有权限的用户可以添加相片,然后用views模块查询,Arguments添加Uid作为URL传递,路径为photos,意图访问连接photos查看全部会员上传的照片,photos/Uid为某个会员的相册,并为每个会员增加一个菜单连接,不过问题出在Uid传递上,后经drupalchina的Loocor帮助终于实现,不过方法不太一样。

他的做法是判断用户是否登陆来传递URL路径,未登陆的用户的菜单是连接到全部会员的相册,已登陆会连接到个人的相册。

Argument 的Uid 中Action to take if argument is not present:项选择Provide default argument

Default argument type:选PHP Code

PHP argument code:

global $user;/*是否为登录用户*/
if ($user->uid){/*如果是当前浏览者为登录用户则显示下面的内容*/
    return $user->uid;
}

评论

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <img> <em> <del> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <h3> <h4> <h5> <h6>
  • 自动断行和分段。
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.