vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Inserting a template via SQL Query (https://vborg.vbsupport.ru/showthread.php?t=269475)

Artashes 08-31-2011 07:53 PM

Inserting a template via SQL Query
 
Hello

I am trying to insert new templates via SQL from an external application with the vb database as its database.

The template itself is being inserted correctly into the database. I have made it so that if the template name i supply my script with matches a template name in the database it copies the code (template and template_un), otherwise the template is blank.

This is all acting as I want it.

However, when I make modifications to a template which has the same name as a vb default, it does not result in any of the changes being made to the theme. In fact, when I go to the style manager in the admincp, it does not seem to realise that there is a customised version of the template (it is not red). When I make modifications to the one in the style manager it says that there is already a template and any modifications will override it.

Am I missing something here? How do I get vB to realise that there is a customised version of a default template?

Thanks,

kh99 08-31-2011 08:18 PM

Looking at admincp/template.php in the "if ($_POST['do'] == 'updatetemplate')" section (around line 2236), it looks like if you are changing .css templates you need to call build_style() after (in includes/adminfunctions_template.php). Also if you change a template starting with 'bbcode_' you need to truncate the 'postparsed' table (but I'm guessing that's not part of the problem you're having).

Artashes 08-31-2011 08:39 PM

Aye. That's where I've been looking. The templates are neither bbcode nor css, so it doesn't apply :(

I do everything that template.php does, I think!

This is the data I'm entering:

PHP Code:

            $data = array(
                
'templateid'   => ''
                
'styleid'      => $tStyleId,
                
'title'        => $name,
                
'template'     => $tTemplate,
                
'template_un'  => $tTemplateUn,
                
'templatetype' => 'template',
                
'dateline'     => $tTime,
                
'username'     => 'Artashes',
                
'version'      => '4.1.5',
                
'product'      => 'vbulletin',
                
'mergestatus'  => 'none' 
            
);

            if(
$this->db->insert('template'$data)){
                return 
TRUE;            
            } else {
                return 
FALSE;
            } 

The app uses CodeIgniter's database driver.

But I don't think this is the problem: everything is entered fine. I'll try entering a row into the adminlog.

kh99 08-31-2011 08:51 PM

I was looking at the wrong section. When you're modifying a template for a style that was inheriting that template, $_POST['do'] is set to 'inserttemplate'. In that section of the code it always calls print_build_style().

Edit: Specifically, it looks like the style table has a list of template ids for all templates in that style. Looks like a serialized array of arrays, so maybe if you don't want to call build_style you could try just updating that field.

Artashes 08-31-2011 09:03 PM

You know what? I just discovered that myself! Coincidence much!? Just trying to get it to work now!

--------------- Added [DATE]1314837575[/DATE] at [TIME]1314837575[/TIME] ---------------

Neither worked for me :(


All times are GMT. The time now is 09:13 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01024 seconds
  • Memory Usage 1,726KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete