Jump to content

Probably a very newbie question...


jamesi

Recommended Posts

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

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";

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.