x
 
Create New Page

Revision: TShoot Categories Added After Update Dont Display

Revision from: 11:40, 12 Jul 2007

Question: I’ve updated my site to version 1.6 of ExpressionEngine. However, when I try to view some of my categories, the category_id isn’t showing up.

Answer: This problem is caused by an early build of EE 1.6. You’ll need to update to a more recent build of 1.6, and run the following PHP code in a template (PHP set to incoming).

<?php
global $DB;

$cats = array();

$query = $DB->query("SELECT cat_id FROM exp_category_field_data");

if (
$query->num_rows > 0)
{
foreach ($query->result as $row)
{
  $cats[]
= $row['cat_id'];
}
}

$query
= $DB->query("SELECT cat_id, group_id, site_id FROM exp_categories");

if (
$query->num_rows > 0)
{
foreach ($query->result as $row)
{
  
if (! in_array($row['cat_id'], $cats))
  
{
   $DB
->query($DB->insert_string('exp_category_field_data',
array(
'cat_id' => $row['cat_id'],
   
'group_id' => $row['group_id'], 'site_id' => $row['site_id'])));
  
}
}
}

?>

NOTE: You won’t see any output from this script, but your category_id problems will be fixed.

Category:Troubleshooting

Categories: