We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Getting category url title from php or API .

Development and Programming

hagcin's avatar
hagcin
14 posts
14 years ago
hagcin's avatar hagcin

I was looking at the manual here: http://ellislab.com/expressionengine/user-guide/development/api/api_channel_categories.html#id4

And none of the category functions return the url title of the category for some strange reason. How can I go about getting the url title from a category once I have the id in PHP?

I need the URL title to generate a link in the URL for someone to click on.

Here is my code if it at all helpful: it all works I just don’t now how to get the url title.

<?php
   $aOtherTrainingsLink = ''; $aCoreTainingLink = '';
         if('{class_student}' != '')
   {
    $aStudentProfileClassID = explode ( '|' , '{class_student}');

    $this->EE->load->library('api');
    $this->EE->api->instantiate('channel_categories');
    $aCat = $this->EE->api_channel_categories->category_tree(1);    /* GET an array listing of categories on category group 1 */
    foreach ($aCat  as $aCatRow)
    {
     foreach($aStudentProfileClassID as $iStudentIDValue)
     {
      if($iStudentIDValue == $aCatRow[0] && $aCatRow[6] == 24)  /*{class_student} == category_id and category group_id = 24 */
      {
                      /* echo "DEBUG: we have a core group match HERE!:".$aCatRow[0]. $aCatRow[1] . $aCatRow[6] . "
"; */ 
       $aCoreTainingLink[] = '<a >'.$aCatRow[1].'</a>';
      }
      elseif($iStudentIDValue == $aCatRow[0] && $aCatRow[6] != 24)
      {
          $aOtherTrainingsLink[] = '<a >'.$aCatRow[1].'</a>';
      }

     }
        
    }
          }
    //DISPLAY CORE TRAININGS
    echo "<h2>Core Trainings</h2>";
    foreach($aCoreTainingLink as $sValue){ echo $sValue."\n"; }

          echo "<h2>Other Classes</h2>";
    if($aOtherTrainingsLink != ''){
      foreach($aOtherTrainingsLink as $sValue){ echo $sValue."\n"; }
    }else{
    echo "Feel Free to Sign up for another class";
    }
          //echo "DEBUG:".  print_r($aCat);
   
       ?>
       
Dan Decker's avatar
Dan Decker
7,338 posts
14 years ago
Dan Decker's avatar Dan Decker

Hi hagcin,

There are some oddities when using the API, that’s for sure! We don’t actually provide support for add-on development, but I have an idea that should set you up nice.

You will need to use a regular database call to get what you are looking for:

$query = $this->EE->db->get_where('categories', array('cat_id' => $aCatRow[0]));

I’m going to move this over to Development and Programing to get you in the proper Community.

Thanks!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.