PDA

View Full Version : Update style through sql cmd


MegaManSec
11-15-2012, 12:31 AM
Hey there.

I've got the current code:

$vbulletin->db->query_write("update " . TABLE_PREFIX . "template set template_un='Dont forget to check out our newest newsletter!' WHERE title='ad_navbar_below'");

It works and all, but it doesn't appear on the page.

When I go to the style manually, it's there, and for it to show, I need to do "Save&Reload" so I think I have to automate the "reload style" part.

How do I do that/

Thanks

kh99
11-15-2012, 01:05 AM
You also need to set the 'template' field to the compiled template, which you can get like this:

$template_un = "Some message";

require_once(DIR . '/includes/adminfunctions_template.php');
$template = compile_template($template_un);

MegaManSec
11-15-2012, 01:11 AM
You also need to set the 'template' field to the compiled template, which you can get like this:

$template_un = "Some message";

require_once(DIR . '/includes/adminfunctions_template.php');
$template = compile_template($template_un);


Okay, so this should work:
require_once(DIR . '/includes/adminfunctions_template.php');

$template_un = 'message';
$template = compile_template($template_un);

$vbulletin->db->query_write("update " . TABLE_PREFIX . "template set template_un='" . $template_un . "' WHERE title='ad_navbar_below'");

$vbulletin->db->query_write("update " . TABLE_PREFIX . "template set template='" . $template ."' WHERE title='ad_navbar_below'");
?

Thanks

--------------- Added 1352945845 at 1352945845 ---------------

Actually, Scratch that.
I mean;

require_once(DIR . '/includes/adminfunctions_template.php');

$template_un = 'message';
$template = compile_template($template_un);

$vbulletin->db->query_write("update " . TABLE_PREFIX . "template set template_un='" . $template_un . "' WHERE title='ad_navbar_below'");

? I tried it, but it doesn't update on the main page.
Still requires me to press the save and reload button in the styles manager.

--------------- Added 1352947788 at 1352947788 ---------------

Think I've found it.
print_rebuild_style

Let's see.. I'll test it out now.

--------------- Added 1352948337 at 1352948337 ---------------


require_once(DIR . '/includes/adminfunctions_template.php');

$template_un = 'message';
$template = compile_template($template_un);

$vbulletin->db->query_write("update " . TABLE_PREFIX . "template set template_un='" . $template_un . "' WHERE title='ad_navbar_below'");

$vbulletin->db->query_write("update " . TABLE_PREFIX . "template set template='" . $final_rendered ."' WHERE title='ad_navbar_below'");
print_rebuild_style(-1, '', 0, 0, 0, 0);
also doesn't work.
makes me have to press save and reload in template.php still..
ugh..

--------------- Added 1352950211 at 1352950211 ---------------

Well, I'm stumped.

I finished w/ this code and it doesnt work either. still requires manual save.
require_once(DIR . '/includes/adminfunctions_template.php');

$template_un = 'messgaaaage';
$template = compile_template($template_un);
$vbulletin->db->query_write("update " . TABLE_PREFIX . "template set template_un='" . $template_un . "' WHERE title='ad_navbar_below'");
$vbulletin->db->query_write("update " . TABLE_PREFIX . "template set template='" . $final_rendered . "' WHERE title='ad_navbar_below'");
$vbulletin->db->query_write("update" . TABLE_PREFIX . " template set dateline = " . TIMENOW . " WHERE title='ad_navbar_below'");
print_rebuild_style(-1, '', 0, 0, 0, 0);

--------------- Added 1352960530 at 1352960530 ---------------

...Got it!!

Just for future reference, this is how to do it:


require_once(DIR . '/includes/adminfunctions_template.php');

$template_un = "lol7";
$template = compile_template($template_un);
$vbulletin->db->query_write("update " . TABLE_PREFIX . "template set template_un='" . $template_un . "' WHERE title='ad_navbar_below'");

$vbulletin->db->query_write("update " . TABLE_PREFIX . "template set template='" . addslashes($template) . "' WHERE title='ad_navbar_below'");

$vbulletin->db->query_write("update" . TABLE_PREFIX . " template set dateline = " . TIMENOW . " WHERE title='ad_navbar_below'");
print_rebuild_style(-1, 'ad_navbar_below', 0, 0, 0, 0);
build_style_datastore();