SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast gullsinn's Avatar
    Join Date
    Apr 2009
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP directory need help with catagories

    i am running a link directory written in PHP
    i need help with an issue :
    my visitor can post his link in top level category and i want to disallow this
    i want if a user is on top level category the submitlink should be disabled and when he is in subcategories he should be allowed to post link

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    And what exactly is your problem? Do you have some code you're working on?

  3. #3
    SitePoint Enthusiast gullsinn's Avatar
    Join Date
    Apr 2009
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    And what exactly is your problem? Do you have some code you're working on?
    yes i have a complete code and working properly but the problem is i want to display my top_bar.tpl file only in it would start from second page

    same like as dmoz dot org project you can see in main page the top_bar.tpl containing 3 button and after 3 clicks it show more the three

  4. #4
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The information you have given is not sufficient to offer you a meaningful response. Be more specific, single out the area of the code that you think needs to be worked on and post it.

  5. #5
    SitePoint Enthusiast gullsinn's Avatar
    Join Date
    Apr 2009
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    more specification is that the file top_bar.tpl have 5 buttons and by default every page includes top_bar.tpl with five buttons i wrote top_bar_2.tpl with 3 buttons
    i want to make changes
    "on man page i need top_bar_2.tpl having 3 buttons"
    "every else after 2nd click i want to include top_bar.tpl havng 5 buttons and remove top_bar_2.tpl"

    this is the first page /arts/



    this is the second page /arts/animations/


  6. #6
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Yes, we understand that. But if you don't show us the code where you're trying to achieve this, we can't help you.

  7. #7
    SitePoint Enthusiast gullsinn's Avatar
    Join Date
    Apr 2009
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i am learner and very new to php but think i have to work on code located bellow
    how: ??
    i don't know
    Code:
    //Determine category
    $CategoryID = (!empty($_REQUEST['c']) && preg_match ('`^[\d]+$`', $_REQUEST['c']) ? intval ($_REQUEST['c']) :
                   (!empty ($_SERVER['HTTP_REFERER']) ? get_category($_SERVER['HTTP_REFERER']) : 0));
    $CategoryID = ($CategoryID > 0 ? $CategoryID : 0); //Make sure the category ID is valid
    
    if (empty ($_REQUEST['submit']))
    {
    	if (!empty ($_SERVER['HTTP_REFERER']))
    		$_SESSION['return'] = $_SERVER['HTTP_REFERER'];
    
    	$data = array ();
       $data['CATEGORY_ID'] = $CategoryID;
    	$data['RECPR_REQUIRED'] = $recpr_required;
    so please take a look at and suggest some thing possibilities

  8. #8
    SitePoint Enthusiast gullsinn's Avatar
    Join Date
    Apr 2009
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i also tried with removing
    {include topbar.tpl} in main but in this case it disappear on whole web and i want it in next step

  9. #9
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The first thing you need is a way to determine whether the categoryID is the one that belongs to the top level category or to a subcategory.

    If I knew the table structure for category, I probably could have helped you craft a SQL query to determine if it’s a top level directory or a subdirectory. Since that’s not the case, I’ll give you a generic solution.

    Fetch all top level category IDs by executing whatever SQL query is appropriate and store them in an array.

    Find the current character ID. Apparently, it’s stored in $CategoryID in your code.

    Now, check if the $CategoryID is also available in the array. If yes, you are currently in the main page and therefore top_bar_2.tpl. On the other hand if the category id is missing in the array, you can safely assume that you are in a subcategory page. include top_bar.top in this case.


    Code PHP:
    <?php
      //populate the following array with top level category ids. 
      //use appropriate SQL query if categories are saved in a database
      $topLevelCategories = array(1, 2, 3);
     
      if(in_array($CategoryID, $topLevelCategories)){
        // you are in the main page
        include('top_bar_2.tpl');  
      } else{
        //you are in a subdirectory
        include('top_bar.tpl');
     
      } 
     
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •