Content Type Management

Content Type Management 1.0.3

No permission to download

Chris D

XenForo developer
Staff member
Chris Deeming submitted a new resource:

Content Type Management - Easily manage and rebuild XenForo content types from the Admin CP

Currently the process to create and manage content types is a little bit "clunky".

You have to create the content type in the xf_content_type table. You then have to add your content type fields in the xf_content_type_fields table. You have to write SQL queries for your add-on installer. Finally for your own sanity, you'll want to ensure you've then rebuilt the content types cache.

This add-on is designed to make that process a little bit easier.

In the Development tab (Debug mode required)...

Read more about this resource...
 
great addon:)
thx very much for this!


It would be nice if you would add add the default addonid ($addOnModel->getDefaultAddOnId()) if non addon is selected
PHP:
'addOnSelected' => (isset($contentType['addon_id']) ? $contentType['addon_id'] : $addOnModel->getDefaultAddOnId()),
instead of only
PHP:
'addOnSelected' => $contentType['addon_id']

this way nobody would need to set the addon id, if he has set the default addon id in the configuration file
 
Thank you @xf_phantom :)

I didn't even know you could do that... all that time I have wasted by having to click for the add-on I'm working on ;)
 
Viewing the index gives me the following:

Code:
Template Errors: content_type_management_index

    Invalid argument supplied for foreach() in F:\xampp\htdocs\se7ensins\library\XenForo\Template\Abstract.php(265) : eval()'d code, line 77:

    76:                         ';
    77: foreach ($contentType['fields'] AS $fieldId => $field)
    78: {
 
Actually, never mind. Had a phantom content type that was causing it :p
 
Bug:

When generating the SQL code, backslashes in class names (for namespaces) aren't escaped (a double backslash is needed for a backslash).

Liam
 
A small feedback about the helper provided with the sql code. It certainly depends on the SQL version, but for a maximum compatibility each insertion would require a specific DB query and the final ";" should not be used.
Example:
PHP:
      $db->query("INSERT IGNORE INTO xf_content_type
           (content_type, addon_id, fields)
           VALUES   ('abctype', 'addonid', '')
       ");
       
       $db->query("INSERT IGNORE INTO xf_content_type_field
           (content_type, field_name, field_value)
           VALUES   ('abctype', 'search_handler_class', 'MyClass_Search_DataHandler_AbcType')
       ");
 
  • Like
Reactions: Xon
A small feedback about the helper provided with the sql code. It certainly depends on the SQL version, but for a maximum compatibility each insertion would require a specific DB query and the final ";" should not be used.
Example:
PHP:
      $db->query("INSERT IGNORE INTO xf_content_type
           (content_type, addon_id, fields)
           VALUES   ('abctype', 'addonid', '')
       ");
    
       $db->query("INSERT IGNORE INTO xf_content_type_field
           (content_type, field_name, field_value)
           VALUES   ('abctype', 'search_handler_class', 'MyClass_Search_DataHandler_AbcType')
       ");
I've not made any changes with regards to this.

The SQL output is simply formatted to allow the dev to then do what they wish with it. It would be trivial for me to actually format it into the appropriate PHP syntax, but I didn't want to make your lives too easy ;)

In isolation, though, the MySQL query that is output is fully compatible with MySQL 5.0+. It may just need additional formatting if then being used in PHP code.
 
Chris D updated Content Type Management with a new update entry:

Fixed undefined index error and more

  • Fixed an error when generating SQL code when a content type has no fields assigned.
  • Disabled the error label in the content type field overlay.
  • Changed the SQL code generated so it can now be copy and pasted into your install method, e.g.
PHP:
$db = XenForo_Application::getDb();

$db->query("
    INSERT IGNORE INTO xf_content_type
        (content_type, addon_id, fields)
    VALUES
        ('node', 'XenForo', '')
");

$db->query("
    INSERT IGNORE INTO...

Read the rest of this update entry...
 
A small feedback about the helper provided with the sql code. It certainly depends on the SQL version, but for a maximum compatibility each insertion would require a specific DB query and the final ";" should not be used.
Example:
PHP:
      $db->query("INSERT IGNORE INTO xf_content_type
           (content_type, addon_id, fields)
           VALUES   ('abctype', 'addonid', '')
       ");
      
       $db->query("INSERT IGNORE INTO xf_content_type_field
           (content_type, field_name, field_value)
           VALUES   ('abctype', 'search_handler_class', 'MyClass_Search_DataHandler_AbcType')
       ");
The latest version actually generates the PHP code for easier copy/pasting into install methods.
 
Top Bottom