jamesi Posted June 25, 2010 Share Posted June 25, 2010 I have some coding for a Pligg site I'm running. I want to show only certain categories on the front page... I have this code, which means it shows one category: // Find the current URL $domain = $_SERVER['HTTP_HOST']; $url = "http://" . $domain . $_SERVER['REQUEST_URI']; // echo $url.'<br />'; // echo $my_base_url.$my_pligg_base.'/<br />'; if (($url == $my_base_url.$my_pligg_base.'/') || ($url == $my_base_url.$my_pligg_base.'/index.php')) { // Show the category ID # '13' by default. // echo 'Homepage'; $search->category = "2"; } But I'm not sure of the correct way to show more than one category. Tried repeating the $search category line with a different number, tried commas, tried everything I can think of. The people at Pligg weren't very helpful either! Thanks a lot! Link to comment https://forums.phpfreaks.com/topic/205830-probably-a-very-newbie-question/ Share on other sites More sharing options...
phpchamps Posted June 25, 2010 Share Posted June 25, 2010 use array, $search->category = array(1,2,3,4); if you are using mysql database then query will be $imploded_array = implode(",",$search->category ); select * from tableName where id IN ($imploded_array); code is not tested... Link to comment https://forums.phpfreaks.com/topic/205830-probably-a-very-newbie-question/#findComment-1077110 Share on other sites More sharing options...
phpchamps Posted June 28, 2010 Share Posted June 28, 2010 can you post the full code??? Link to comment https://forums.phpfreaks.com/topic/205830-probably-a-very-newbie-question/#findComment-1078066 Share on other sites More sharing options...
jamesi Posted June 28, 2010 Author Share Posted June 28, 2010 This is the index page (where the code is): <?php // The source code packaged with this file is Free Software, Copyright (C) 2005 by // Ricardo Galli <gallir at uib dot es>. // It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise. // You can get copies of the licenses here: // http://www.affero.org/oagpl.html // AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING". include_once('Smarty.class.php'); $main_smarty = new Smarty; include('config.php'); include(mnminclude.'html1.php'); include(mnminclude.'link.php'); include(mnminclude.'tags.php'); include(mnminclude.'search.php'); include(mnminclude.'smartyvariables.php'); // module system hook $vars = ''; check_actions('index_top', $vars); // find the name of the current category if(isset($_REQUEST['category'])){ $thecat = get_cached_category_data('category_safe_name', sanitize($_REQUEST['category'], 1)); $main_smarty->assign('request_category_name', $thecat->category_name); $catID = $thecat->category_id; $thecat = $thecat->category_name; if (!$thecat) { header("Location: $my_pligg_base/404error.php"); // $main_smarty->assign('tpl_center', '404error'); // $main_smarty->display($the_template . '/pligg.tpl'); die(); } } // start a new search $search=new Search(); // check for some get/post if(isset($_REQUEST['from'])){$search->newerthan = sanitize($_REQUEST['from'], 3);} unset($_REQUEST['search']); unset($_POST['search']); unset($_GET['search']); if(isset($_REQUEST['search'])){$search->searchTerm = sanitize($_REQUEST['search'], 3);} if(isset($_REQUEST['search'])){$search->filterToStatus = "all";} if(!isset($_REQUEST['search'])){$search->orderBy = "link_published_date DESC, link_date DESC";} if(isset($_REQUEST['tag'])){$search->searchTerm = sanitize($_REQUEST['search'], 3); $search->isTag = true;} if(isset($thecat)){$search->category = $catID;} // figure out what "page" of the results we're on $search->offset = (get_current_page()-1)*$page_size; // pagesize set in the admin panel $search->pagesize = $page_size; // since this is index, we only want to view "published" stories $search->filterToStatus = "published"; // Find the current URL $domain = $_SERVER['HTTP_HOST']; $url = "http://" . $domain . $_SERVER['REQUEST_URI']; // echo $url.'<br />'; // echo $my_base_url.$my_pligg_base.'/<br />'; The main code in question is: // Find the current URL $domain = $_SERVER['HTTP_HOST']; $url = "http://" . $domain . $_SERVER['REQUEST_URI']; // echo $url.'<br />'; // echo $my_base_url.$my_pligg_base.'/<br />'; if (($url == $my_base_url.$my_pligg_base.'/') || ($url == $my_base_url.$my_pligg_base.'/index.php')) { // Show the category ID # '13' by default. // echo 'Homepage'; $search->category = "2"; Link to comment https://forums.phpfreaks.com/topic/205830-probably-a-very-newbie-question/#findComment-1078415 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.