would you actually recommend to do a post page (Pods Admin->Components->Pages) and use the function find?
as shown in the documentation: https://pods.io/docs/code/pods/find/
Would the general idea be to create a “Pods Template” to display a single Journal2 Custom Post Type?
and then use a “Pods Page” to code a searching form ?
I’ve looked around the tutorials and documentation but it’s a bit confusing as they are covering topics with a random order; might need to spend more time on it !
-
This reply was modified 6 years, 6 months ago by
allanext.
You have to have an archive for search and filter to work or you have to construct a PHP specifically for their results. We don’t provide support got their plugin as they have their own forum.
Did you reach out to them on their forum?
Hi Jim,
thanks for your response, I think I’ll need to code my search functionality; would you advise doing this with a “Pods Page”?
I’m getting confused.. I’ve looked a bit around but didn’t found a great example.
Thank you
I haven’t found a great example to bootstrap, there’s some documentation and examples, like:
https://pods.io/tutorials/using-pods-pages-advanced-content-types/
https://pods.io/forums/topic/simple-search-box/
http://webdesignforidiots.net/2013/04/pods-pages-and-templates-and-more-pages-oh-my/
For now i’ve roughly created a Pod Page with a form that displays the results on the same page. It looks like it should be better integrated with Pod Templates as it’s giving the following notice:
PHP Notice: Pod Page PHP code has been deprecated, please use WP Page Templates or hook into the pods_content filter instead of embedding PHP. has been deprecated since Pods version 2.1 with no alternative available. in
If somebody could create a proper example it would be great !
Anyways this might give you an idea:
<?php
/*
Template Name: Pod Page Template
*/
get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<header class="banner">
<div class="shadow-wrapper">
<h1 class="banner-title">Byara</h1>
</div>
</header><!-- .banner -->
<div class="block entry-block">
<div class="entry cf px-5">
<h2>Search the collection</h2>
</div>
<form id="searchform" method="get" action="/new-byara">
<input type="text" class="search-field" name="author" placeholder="Author" value="">
<input type="text" class="search-field" name="title " placeholder="Title" value="">
<input type="text" class="search-field" name="year" placeholder="Year" value="">
<input type="text" class="search-field" name="abstract" placeholder="Abstract" value="">
<input type="text" class="search-field" name="keywords" placeholder="Keywords" value="">
<input type="submit" value="Search">
</form>
<div class="entry-content">
<?php
$author = $_GET["author"];
$title = $_GET['title'];
$year = $_GET['year'];
$abstract = $_GET['abstract'];
$keywords = $_GET['keywords'];
//if(isset($_GET["author"])) echo "\nauthor is set\n";
//print_r($_GET);
?>
</div>
<?php
//this is normally where the WP Loop would be. Instead we add a loop to get pods stuff
$mypod = pods('journal');
// Here's how to use find()
$params = array(
'limit' => 20,
'page' => 1,
// Be sure to sanitize ANY strings going here
//'where' =>"author_analytic = '.$author.'"
);
$mypod->find($params);
?>
<table>
<thead>
<tr>
<th>Author</th>
<th>Title</th>
<th>Link</th>
</tr>
</thead>
<tbody>
<?php
// Loop through items found
while ( $mypod->fetch() ) {
$journal_title= $mypod->field('title_analytic');
$permalink= $mypod->field('permalink');
echo "<tr>";
echo "<td>".$mypod->display( 'author_analytic' )."</td>";
echo "<td>".$mypod->display( 'title_analytic' ) ."</td>";
echo "<td>".$permalink.'</td>';
echo "</tr>";
}?>
</tbody>
</table>
<?php echo $mypod->pagination();?>
</div>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
-
This reply was modified 6 years, 6 months ago by
allanext.
Hi @allanext
As stated in the notice. Pods Pages are deprecated and should not be used anymore.
You should use the WordPress default theme templates to create your pages using the theme editor or FTP.
Other than that your code example looks like an ok starting point to continue on.
More info on WordPress theme templates: https://developer.ww.wp.xz.cn/themes/basics/template-files/
Good luck!
Jory
@keraweb Thank you for pointing out in the right direction, very appreciated !