WordPress.org

Ready to get started?Download WordPress

Forums

Media Category Library
[resolved] Creating a template file for my site to allow people so search for media... (3 posts)

  1. tsoheili
    Member
    Posted 1 year ago #

    Creating a template file for my site to allow people so search for media files (PDF's) by categories which are set up by form check boxes Eventually there will be upwards of 50+ categories to check from from different divisions.

    <div id="content-sidebar-wrap">
        <div id="content" class="hfeed">
            <?php the_content(); ?>
    		<? echo "<h1 class=\"entry-title\">Category Filtering</h1>";?>
            <div id="category-options">
                <form method="post" action="">
                    <p><input id="papers" type="checkbox" name="papers" value="Featured Paper, Feature Papers, Second Edition, Second Editions, Student Paper, Student Papers"><label for="papers"> Papers</label></p>
                    <p><input id="articles" type="checkbox" name="articles" value="Commentary, Commentaries, Articles, Advisory Article, Advisory Articles, Series Article, Series Articles"><label for="articles"> Articles</label></p>
                    <p><input id="book-reviews" type="checkbox" name="book-reviews" value="Book Review, Book Reviews">
                    <input type="hidden" name="cats" value="1"><label for="book-reviews">Book Reviews</label></p>
                    <input type="submit" name="submit" value="Submit">
                </form>
            </div>
            <div id="category-results">
                <?php
                if(isset($_POST['cats'])) {
                    $cats = "";
                    $comma = ", ";
    
                    //check if the papers checkbox was clicked and update the categories to filter by
                    if(isset($_POST['papers'])) {
                        $cats = mysql_real_escape_string(htmlentities($_POST['papers']));
                    }
    
                    //check if the articles checkbox was clicked and update the categories to filter by, accordingly
                    if(isset($_POST['articles'])) {
                        if(isset($cats)) { $cats = $cats.$comma; }
                        $cats = mysql_real_escape_string(htmlentities($_POST['articles']));
                    }
    
                    //check if the book-reports checkbox was clicked and update the categories to filter by, accordingly
                    if(isset($_POST['book-reports'])) {
                        if(isset($cats)) { $cats = $cats.$comma; }
                        $cats = mysql_real_escape_string(htmlentities($_POST['book-reports']));
                    }
    
                    $str = '[mediacat cats="$cats" orderby="date" order="DESC"]';
                    echo do_shortcode($str);
                ?>
            </div>
        <?php } ?>
        </div>
    <!-- end #content -->

    When running the page I get the following result after turning on php errors to display so I could have some information to give you.

    Notice: Undefined offset: 0 in /home/pmwl/public_html/wp-includes/query.php on line 2249

    See the page below:
    http://pmworldlibrary.net/pm-world-collection/by-pmwj-category/

    Notice: Undefined index: returnposts in /home/pmwl/public_html/wp-content/plugins/media-category-library/classes/media-category-library.php on line 707

    http://wordpress.org/extend/plugins/media-category-library/

  2. tsoheili
    Member
    Posted 1 year ago #

    $str = '[mediacat cats="'.$cats.'" orderby="date" order="DESC"]';

    That solved that problem and it seems to be working but before I turn off the php errors I did notice the following notice...

    Notice: Undefined index: returnposts in /home/pmwl/public_html/wp-content/plugins/media-category-library/classes/media-category-library.php on line 707

  3. tsoheili
    Member
    Posted 1 year ago #

    I figured this out and it was a silly php string oversite. I just have too much going on, namely the other ticket I have out there with you. http://wordpress.org/support/topic/series-of-check-boxes?replies=1

    This ticket is on the media edit or add pages displaying checkboxes below the input box for my chosen categories. This will help my data entry team that will be a fairly high turn over position of student workers from semester to semester from creating typos that will affect the results of our library site.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.