Wordpress、PodCMS 和搜索

发布于 2024-08-30 03:09:05 字数 474 浏览 9 评论 0原文

我有一个客户的 WordPress 网站。他拥有一家音像商店,我为他创建了一个网站来更新电影列表,通常只是“本周新”电影。

我使用 PodCMS 作为他上传电影然后显示它们的简单方法。他甚至不需要创建帖子。效果非常好,这是一个很棒的扩展,我只是遇到了一些问题。

Pod 有一个字段,您可以在其中插入发布日期。 2010-04-20
然后有一个 Pod 页面/模板组合,可以调用具有特定发行日期的电影,如下所示:
$date = pods_url_variable('last');
然后,他使用 slug 2010-04-20
创建一个空白 WP 页面 因此,当您打开该页面时,Pod 页面/模板会读取该 slug 并呈现相应电影的列表。

我的问题: 我需要这些可以被搜索。这可能吗。

我也愿意接受有关使该网站正常运行的其他方法的建议。我需要它就这么简单。上传一些电影并创建一个新页面。然后剩下的就自动完成了。

I have a WordPress site for a client. He owns a video store, and I made a site for him to update the list of movies, usually just the "new this week" movies.

I used PodCMS as an easy way for him to upload movies and then display them. No need for him to even create posts. Works really well, it's a great extension, I'm just having some issues.

The Pod has a field where you insert the release date. 2010-04-20
Then there is a Pod page/template combo that calls the movies with a certain release date like this:
$date = pods_url_variable('last');
He then just creates a blank WP page with the slug 2010-04-20
So when you open that page, the Pod page/template reads that slug and renders a list of the appropriate movies.

My problem:
I need these to be searchable. Is this possible.

I'm also open to suggestions on other ways to go about making this site work. I need it to be as simple as that. Uploads some movies and creates a new page. Then the rest is done automatically.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酒儿 2024-09-06 03:09:05

PodsCMS 搜索只不过是对搜索词进行 mySQL 表搜索。您可以搜索标题、正文,几乎任何内容。下面是一个示例:

注意:我使用“whatever”作为 pod 信息。我还形成了一个进入 $where 位置的字符串,其中包含我想要搜索的各种 pod 变量。另外,我假设使用 Pods 分页控件进行分页,但我希望跨页面携带该变量,以便可以进行偏移。

<?php

$search_term = $_GET["s"];
$paged = get_query_var('paged');
$page_number = $_GET['pg'];

?>

<h1>
      Results for "<?php echo $search_term; ?>"<?php if($page_number > 1){ ?> (Continued)<?php } ?><?php if($paged > 1){ ?> (Continued)<?php } ?>
  </h1>

  <?php if($paged <= 1){ ?>
  <h2>Results in Whatever...</h2>

      <?php
            $whateverSentence = "(t.name LIKE '%" .$search_term. "%') || (t.whatever LIKE '%" .$search_term. "%')";
            $whatever = new Pod('whatever');
            $whatever->findRecords($orderby = 't.whatever DESC', $rows_per_page = 5, $where = $whateverSentence, $sql = null);
            $total_whatever = $whatever->getTotalRows();
      ?>
      <?php if( $total_whatever >0 ) : ?>
      <?php while ( $whatever->fetchRecord() ) : ?>
      <?php
            // Set Variables
            $whatever_ID = $whatever->get_field('id');
            $whatever_Permalink = $whatever->get_field('slug');
            $whatever_Name = $whatever->get_field('name');

    ?>

Code that echos the pods variables and represents the search result

<?php endwhile ?>

<?php else: ?>

<p>Sorry, no results found for that search.</p>

<?php endelse; endif ?>
<?php echo $whatever->getPagination($label = '<span class="pagination-text">Go to page:</span>'); ?>


<?php } ?>

A PodsCMS search is nothing more than a mySQL table search for the search term. You can search the title, body, pretty much anything. Here's an example:

Note: I'm using "whatever" as the pod info. I'm also forming a string that goes into the $where position which comprises the various pods variables I want to search on. Also, I'm assuming pagination using the Pods pagination controls but I want that variable carried across the pages so I can offset.

<?php

$search_term = $_GET["s"];
$paged = get_query_var('paged');
$page_number = $_GET['pg'];

?>

<h1>
      Results for "<?php echo $search_term; ?>"<?php if($page_number > 1){ ?> (Continued)<?php } ?><?php if($paged > 1){ ?> (Continued)<?php } ?>
  </h1>

  <?php if($paged <= 1){ ?>
  <h2>Results in Whatever...</h2>

      <?php
            $whateverSentence = "(t.name LIKE '%" .$search_term. "%') || (t.whatever LIKE '%" .$search_term. "%')";
            $whatever = new Pod('whatever');
            $whatever->findRecords($orderby = 't.whatever DESC', $rows_per_page = 5, $where = $whateverSentence, $sql = null);
            $total_whatever = $whatever->getTotalRows();
      ?>
      <?php if( $total_whatever >0 ) : ?>
      <?php while ( $whatever->fetchRecord() ) : ?>
      <?php
            // Set Variables
            $whatever_ID = $whatever->get_field('id');
            $whatever_Permalink = $whatever->get_field('slug');
            $whatever_Name = $whatever->get_field('name');

    ?>

Code that echos the pods variables and represents the search result

<?php endwhile ?>

<?php else: ?>

<p>Sorry, no results found for that search.</p>

<?php endelse; endif ?>
<?php echo $whatever->getPagination($label = '<span class="pagination-text">Go to page:</span>'); ?>


<?php } ?>
晨敛清荷 2024-09-06 03:09:05

那么您需要 WordPress 页面内容(电影列表)可供搜索吗?

WP 本身并不搜索页面,但会使用 WordPress › 搜索所有内容 « WordPress 插件 并使用 WordPress › Relevanssi « WordPress 插件 进行更好的搜索

So you need the WordPress page content - the list of movies - to be searchable?

WP doesn't search pages natively, but will with WordPress › Search Everything « WordPress Plugins and search better with WordPress › Relevanssi « WordPress Plugins

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文