pods 使用

If someone mentions the term Content Management System, probably WordPress, Joomla, Drupal, and others come to mind. But the only content types supported by WordPress out of the box are pages and articles, which is fine for most websites, but what if you want more? Luckily you can use the Pods Framework; it’s a WordPress plugin which enables you to add custom content types and their management to your WordPress installation.

如果有人提到“内容管理系统”一词,可能会想到WordPress,Joomla,Drupal等。 但是WordPress所支持的唯一现成的内容类型是页面和文章,这对大多数网站都很好,但是如果您想要更多呢? 幸运的是,您可以使用Pods框架; 它是一个WordPress插件,可让您向WordPress安装中添加自定义内容类型及其管理。

I’ll show you some of Pods Framework’s functionality by giving you a quick tutorial on how you we can use it to make a library site. The site will contain an overview page with all of the books we currently have, and when the user clicks on a book link he’ll see its details.

我将通过快速教程向您展示Pods Framework的一些功能,介绍如何使用它来创建图书馆站点。 该站点将包含一个概述页面,其中包含我们当前拥有的所有书籍,当用户单击书籍链接时,他会看到其详细信息。

添加内容类型 (Adding Content Types)

First you have to install the framework. Just use the plugin installer in your WordPress backend like you always do; the full name of the plugin is Pods CMS Framework.

首先,您必须安装框架。 像往常一样,只需在WordPress后端中使用插件安装程序即可; 插件的全名是Pods CMS Framework 。

After installation, click on the Pods menu item in the side menu. Like the description says, a pod is a named group of input fields, which means that it’s a custom content type with properties which you define. Click the “Add new pod” button and create a pod named “books”.

安装后,单击侧面菜单中的Pods菜单项。 就像描述中说的那样,窗格是一组命名的输入字段,这意味着它是具有定义的属性的自定义内容类型。 单击“添加新窗格”按钮,然后创建一个名为“书”的窗格。

After you make the book pod, the screen changes to show its properties:

制成书夹后,屏幕将更改以显示其属性:

By default, our new pod already has the columns name and slug. In this example, we won’t need slug, so just click the red X to the left of it to delete it. The book does however need some more information, such as its publisher, description, genre, author, publication date, and the book cover. Let’s create them now.

默认情况下,我们的新容器已经具有列名和子段。 在此示例中,我们不需要塞子,因此只需单击它左侧的红色X即可将其删除。 但是,这本书确实需要更多信息,例如出版商,描述,体裁,作者,出版日期和书的封面。 现在创建它们。

At the right you’ll see the ‘Add Column’ section. Enter appropriate column names in the Machine Name field and use ‘Single Line Text’ for the Column Type, except for the publication date and description. The type for the publication date should be Date, and the description should be ‘Paragraph Text’. As for the cover, we can just store an URL string to the image.

在右侧,您会看到“添加列”部分。 在机器名称字段中输入适当的列名称,并使用“单行文本”作为列类型,但发布日期和说明除外。 发布日期的类型应为“日期”,描述应为“段落文本”。 至于封面,我们只需将URL字符串存储到图像即可。

页面和模板 (Pages and Templates)

Once the pod is configured, go back to the side Pods menu and click Add book.

设定好广告连播后,返回侧面的“广告连播”菜单,然后单击“添加书籍”。

Add a few of your favorite books as an example, providing the necessary information and saving your work.

添加一些您喜欢的书作为示例,提供必要的信息并保存您的工作。

To display our pages correctly, we’ll need to make a small theme modification. Go to the theme’s directory (I’m using Twentyeleven for this example) and create a new file named pods.php. The content should be:

为了正确显示我们的页面,我们需要进行一些小的主题修改。 转到主题的目录(在此示例中,我使用的是Twentyeleven)并创建一个名为pods.php的新文件。 内容应为:

<?php
/*
Template Name: Custom Pods template
*/
get_header();
?>
<div id="primary">
<div style="width: 93%;" id="content" role="main">
<article id="post-0" class="post page hentry">
<?php pods_content(); ?>
</article>
</div>
</div>
<?php
get_sidebar();
get_footer();
?>

Be sure to include the Template Name comment at the top of the file. This way, WordPress will detect it as template file and name it the same way you named it.

确保在文件顶部包含模板名称注释。 这样,WordPress会将其检测为模板文件,并以与您命名相同的方式对其进行命名。

Now for our visitors to see the book collection we need to create the listing page to show all the books which are currently in the database. Go to Pods’ Setup menu, then the Pages tab, and then click ‘Add new page’. Name it ‘books’.

现在,为了让访问者看到图书集合,我们需要创建列表页面以显示数据库中当前的所有图书。 转到Pods的“设置”菜单,然后转到“页面”标签,然后单击“添加新页面”。 将其命名为“书”。

You should now see a text field where you can enter the code you want for that page. You can include HTML, Javascript, CSS and PHP. Use the following:

现在,您应该看到一个文本字段,您可以在其中输入该页面所需的代码。 您可以包括HTML,Javascript,CSS和PHP。 使用以下内容:

<h1><b>Book List</b></h1>
<?php
$pods = new Pod('book');
$pods->findRecords('id DESC', 10);
while ($pods->fetchRecord()) {
echo '<li><a href="/book/' . $pods->get_field('id') . '">' . $pods->get_field('name') . '</a></li>'; //Create a link to each different book
}
?>

Then, set the Page Template select to ‘Custom Pods Template’ and save your work.

然后,将页面模板选择设置为“自定义窗格模板”并保存您的工作。

In order to view the pages correctly, there’s one additional configuration change we need to make. Go to Settings > Permalinks, select ‘Custom Structure’, and in the text field type ‘/%postname%/’. Now you should be able to view the page you just created by going to yoursite.com/books.

为了正确查看页面,我们需要进行另一项配置更改。 转到“设置”>“永久链接”,选择“自定义结构”,然后在文本字段中键入“ /%postname%/”。 现在,您应该可以访问yoursite.com/books来查看刚刚创建的页面。

We still need to create a page which displays the book information, so click Pods’ ‘Add new page’ button again and use the name ‘book/*’. The * is important because it is a wildcard in the URL, in our case the id of the book.

我们仍然需要创建一个显示书籍信息的页面,因此再次单击Pods的“添加新页面”按钮,并使用名称“ book / *”。 *很重要,因为它是URL中的通配符,在本例中是书的ID。

We can retrieve the first wildcard value (and in our case the only one) by with the pods_url_variable() function.

我们可以使用pods_url_variable()函数检索第一个通配符值(在本例中为唯一的pods_url_variable()

This is the code to use for our books/* page:

这是用于我们的book / *页面的代码:

<?php
// store the book’s id into $bookId
$bookId = pods_url_variable(1);
// retrieves all book entries which fullfill the parameter requirement
$params = array('where'=>'t.id = '. $bookId);
$book = new Pod('book', $params);
// the pods is mostly a data class which contains multiple pod objects
while ($book->fetchRecord()) {
// use get_field() to retrieve the value of a specific field
echo '<h1>' . $book->get_field('name') . '</h1><br />';
echo '<img src="' . $book->get_field('cover') . '" /><br />';
echo 'Autor: ' . $book->get_field('autor') . '<br />';
echo 'Publisher: ' . $book->get_field('publisher') . '<br />';
echo 'Release date: ' . $book->get_field('release') . '<br />';
}
?>

Now we can easily manage our book collection and show it to the world. You can see that with the Pods Framework you can easily create a powerful website using WordPress. Actually, the possibilities are almost unlimited since with wildcards you can emulate a routing system that other frameworks might use.

现在,我们可以轻松地管理我们的藏书并将其展示给全世界。 您可以看到,使用Pods Framework,您可以使用WordPress轻松创建功能强大的网站。 实际上,可能性几乎是无限的,因为使用通配符,您可以模拟其他框架可能使用的路由系统。

For more information about the different Pod methods, you can visit the Pods Codex and ask for support in the Pods Forums.

有关不同Pod方法的更多信息,您可以访问Pods Codex,并在Pods论坛上寻求支持 。

Image via Fotolia

图片来自Fotolia

翻译自: https://www.sitepoint.com/turn-wordpress-into-a-cms-with-pods-framework/

pods 使用

pods 使用_使用Pods Framework将WordPress变成CMS相关推荐

  1. 2021 年使用 WordPress 作为 CMS 的 25 个热门网站

    想知道如何将 WordPress 用作 CMS? 关于 WordPress 最常见的误解之一是它只是一个博客软件.你们中的一些人经常向我们询问 WordPress 用作 CMS 平台(内容管理系统)而 ...

  2. ASP网站整站程序PHP源码-打听网(wordpress打造cms)-wordpress-cms整站打包程序-毕设源码实例

    ASP网站整站程序PHP源码-打听网(wordpress打造cms)-wordpress-cms,整站打包程序,毕设源码实例,用wordpress中文做成的源码.全站打包,可以自行修改就行. 使用PH ...

  3. iOS pods组件化私有的framework 、xcframework

    一.framework制作: 参考: iOS framework制作.脚本合并_m0_47450499的博客-CSDN博客iOS framework制作.脚本合并https://blog.csdn.n ...

  4. 城市简码_如何使用简码在WordPress中添加Twitter Bootstrap CSS

    城市简码 Adding CSS elements like tooltips, colorful buttons, and roll-over effects can help your conten ...

  5. wordpress插件翻译不生效_新的恶意软件利用wordpress插件漏洞攻击数百万网站

    研究人员发现,正在进行的一项针对数百万WordPress网站的恶意攻击活动,目的是利用后门和各种WordPress插件漏洞进行感染. 据wordpress统计,wordpress内容管理系统提供了近6 ...

  6. oracle精简版_使用Entity Framework Core访问数据库(Oracle篇)

    前言 哇..看看时间 真的很久很久没写博客了 将近一年了. 最近一直在忙各种家中事务和公司的新框架  终于抽出时间来更新一波了. 本篇主要讲一下关于Entity Framework Core访问ora ...

  7. wordpress 外部数据接口_使用接口方式获取WordPress用户信息的方法

    今天WordPress主题站简单介绍一下WordPress系统中用户信息获取方式,今天就讲讲使用接口方式获取WordPress用户信息的方法. 接口文件如下: if ('POST' != $_SERV ...

  8. restlet使用_使用Restlet Framework构建联网汽车

    restlet使用 您的汽车有一天会受到开源软件的控制吗? 在开放源代码的Restlet Framework项目的帮助下, 爱立信研究公司正在认真对待这个问题,该项目中,一条简单的短信可以在您返回汽车 ...

  9. 用python输出所有的玫瑰花数_用Python爬取WordPress官网所有插件

    转自丘壑博客,转载注明出处 前言 只要是用WordPress的人或多或少都会装几个插件,可以用来丰富扩展WordPress的各种功能.围绕WordPress平台的插件和主题已经建立了一个独特的经济生态 ...

最新文章

  1. Xcode 创建.a和framework静态库(转)
  2. 前端学习(1960)vue之电商管理系统电商系统之分类参数的基本结构
  3. mysql 视图 分页_mysql查看所有存储过程,函数,视图,触发器,表,分页
  4. MinIO部署快速入门
  5. linux yum选择版本mysql_linux yum安装指定版本mysql
  6. thinkphp5与thinkphp3.X对比
  7. UVA725 UVALive5362 Division【暴力+进制】
  8. 《Entity Framework 6 Recipes》中文翻译系列 (24) ------ 第五章 加载实体和导航属性之查询内存对象...
  9. 深入解读Linux进程调度系列(总览)
  10. 简单的Flash网络游戏源代码
  11. android 下载服务器的txt文档
  12. mysql5.730_MySQL 5.7 Group Replication错误总结(r11笔记第84天)
  13. 机器学习——随机森林算法及原理
  14. 计算机小高考要点,小高考的复习计划
  15. Mybatis在xml文件中处理大于号小于号的方法
  16. 最佳平方逼近 matlab,最佳平方逼近的Matlab
  17. 判断一张图片是否是空白图
  18. 2.STM32F4/7点灯
  19. PAT-A1011 World Cup Betting (世界杯赔率)
  20. 比尔·盖茨是奸商吗?

热门文章

  1. 丝瓜调和蜂蜜轻易“祛斑”
  2. linux修改组命令groupmod,添加用户useradd,修改用户usermod,添加组groupadd
  3. 袁琳 湖北 计算机 导师,袁琳
  4. Python爬虫详解:爬虫是什么,如何做爬虫?
  5. 洛谷 P1582 倒水
  6. 永恒之塔为什么连接服务器中断,win7系统下永恒之塔无法连接到认证服务器如何解决...
  7. access sql 取余_SQL 教程
  8. SpaceX大裁员!苹果道歉了!|一周硅谷热点新闻回顾
  9. android 加密指定文件系统,基于android系统的加密文件系统设计
  10. 施乃俺:三大搜索引擎(百度 谷歌 雅虎)导航站登陆渠道