vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Automatic Template Edits (https://vborg.vbsupport.ru/showthread.php?t=258536)

TheInsaneManiac 02-08-2011 03:45 AM

Automatic Template Edits
 
I am trying to get:
{vb:raw affiliation}

To display my affiliation template within the forumhome template, but I am having no luck. It doesn't display anything when I place {vb:raw affiliation} in my FORUMHOME template.

hook - global_start
Code:

$templater = vB_Template::Create('affiliation');
vB_Template:reRegister('FORUMHOME',array('affiliation' => $affiliation));
$affiliation .= $templater->render();


Andreas 02-08-2011 04:41 AM

PHP Code:

$templater vB_Template::create('affiliation');
vB_Template:preRegister('FORUMHOME', array('affiliation' => $templater->render())); 


TheInsaneManiac 02-08-2011 05:12 AM

I get a server error when using that code.

Lynne 02-08-2011 04:39 PM

You need to create and render a template and then preregister that variable for use in another template.

PHP Code:

$templater vB_Template::Create('affiliation');
// register any variables for use in your affiliation template here
$affiliation .= $templater->render();

vB_Template::preRegister('FORUMHOME',array('affiliation' => $affiliation)); 

Now use {vb:raw affiliation} in your FORUMHOME template.

Also, if you look up the hook global_start in the files, you'll see this:
PHP Code:

// Deprecated as of release 4.0.2, replaced by global_bootstrap_init_start
($hook vBulletinHook::fetch_hook('global_start')) ? eval($hook) : false

It's been deprecated for about a year now.

TheInsaneManiac 02-09-2011 10:17 PM

I used global_start with no problems, but as soon as I add your code, I get server errors. It works no problem before the code was added. Hooks work fine, but I would like to be able to place it anywhere in the forumhome. As soon as I add your code in place of mine, I get server errors.

Code:

                        $templater = vB_Template::create('affiliation');
                        $template_hook[forumhome_wgo_pos5] .= $templater->render();


Lynne 02-09-2011 11:17 PM

You can't add exactly my code since I didn't input any variables to register in your template. Also, we can't help with errors if you don't tell us exactly what error you are getting. It would also help to actually see the affiliation template code.

Also, I accidentally wrote "reRegister" instead of "preRegister" in mine above which I have since fixed.
Also, <center> tags still work these days also, but they are deprecated. One of these days they will stop working, just as the global_start hook location will stop working. I've always figured it's best to fix that now, rather than when it gets broken, but that is your call.What is the code you posted for?

TheInsaneManiac 02-09-2011 11:40 PM

What variables, this is what I don't understand. I don't have any variables. I simply just want the affiliation code to display in forumhome.

If global_start and center are going to be gone soon, what will be their replacing counterparts? Everyone uses <center> I don't know why it would be depreciated...

Boofo 02-09-2011 11:43 PM

Quote:

Originally Posted by Andreas (Post 2160074)
PHP Code:

$templater vB_Template::create('affiliation');
vB_Template:preRegister('FORUMHOME', array('affiliation' => $templater->render())); 


I've never seen it done like this before. Does this actually work?

TheInsaneManiac 02-09-2011 11:51 PM

Quote:

Originally Posted by Boofo (Post 2160776)
I've never seen it done like this before. Does this actually work?

No... apparently there are some variables that I don't know about, because it is still not working.

Boofo 02-09-2011 11:54 PM

What hook are you using to call the template from?

TheInsaneManiac 02-09-2011 11:58 PM

global_start, which should I be using?

Boofo 02-10-2011 12:01 AM

Well, if you want it on the forumhome, I would use one of those.

forumhome_start
forumhome_complete -> Most likely, this one

TheInsaneManiac 02-10-2011 12:10 AM

Still get a server error.
Server error.

The website encountered an error while retrieving http://www.consolediscussions.com/forum/forum.php. It may be down for maintenance or configured incorrectly.

Here are some suggestions:
Reload this web page later.

Boofo 02-10-2011 12:13 AM

It comes up fine for me.

TheInsaneManiac 02-10-2011 12:41 AM

Because I reverted back to the old code. Im not just going to leave my website down lol.

Lynne 02-10-2011 01:26 AM

It could be your template is the problem and not your plugin. So I'll ask again if you can you please post your template code.

TheInsaneManiac 02-10-2011 06:08 AM

PMed code

TheInsaneManiac 03-21-2011 06:16 PM

I seriously think someone is playing games.

I added this code:
Code:

                $templater = vB_Template::Create('soundnotification');
                $soundnotification .= $templater->render();
                vB_Template::preRegister('header',array('soundnotification' => $soundnotification));

then $soundnotification to the top of my header template. Cleared cache. All it shows is "$soundnotification" in the source code...

soundnotification template:
Code:

<if condition="$vboptions['sound_notification_enabled']"><if condition="$bbuserinfo['fieldXX'] === 'No'">
                <else />
                <embed src="mail.mp3" autostart="true" hidden="true">
                </if>
                </if>


Lynne 03-21-2011 11:13 PM

No one is playing games, you are just not using the correct vB4 syntax. You cannot put $soundnotification in the template, it is {vb:raw soundnotification}. And you cannot do <if condition... , it is <vb:if (same for other parts of the condition - you are using the wrong syntax).

TheInsaneManiac 03-23-2011 10:50 PM

Still no worky, I put {vb:raw soundnotification} at the top of my header template and it doesn't even show anything in the view source, no sign of the code at all.

Here's my whole xml to prove Im doing everything right, let me add that I've even tried removing the conditionals altogether:
Code:

<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="soundnotification" active="1">
        <title>Sound Notification</title>
        <description>A sound is played when a notification is received.</description>
        <version>2.0</version>
        <url><![CDATA[https://vborg.vbsupport.ru/showthread.php?t=224997]]></url>

<dependencies>
                <dependency dependencytype="vbulletin" minversion="4.0.0" maxversion="4.9.9" />
        </dependencies>
        <templates>
        <template name="soundnotification" templatetype="template" date="1164681507" username="TheInsaneManiac" version="3.8.0"><![CDATA[                <vb:if condition="$vboptions['sound_notification_enabled']"><vb:if condition="$bbuserinfo['fieldXX'] === 'No'">
                <else />
                <embed src="mail.mp3" autostart="true" hidden="true">
                </vb:if>
                </vb:if>]]>
                </template>
        </templates>
<plugins>
        <plugin active="1" product="sound_notification">
                <title>Sound Notification Cache</title>
                <hookname>cache_templates</hookname>
                <phpcode><![CDATA[if ($vbulletin->options['sound_notification_enabled'])
                {
                $cache[] = 'soundnotification';
                }]]></phpcode>
        </plugin>
        <plugin active="1" executionorder="5">
                <title>Sound Notification Begin</title>
                <hookname>global_start</hookname>
                <phpcode><![CDATA[if ($vbulletin->options['sound_notification_enabled'])
                {
                $templater = vB_Template::Create('soundnotification');
                $soundnotification .= $templater->render();
                vB_Template::preRegister('header',array('soundnotification' => $soundnotification));
                }]]></phpcode>
        </plugin>
        <plugin active="1" executionorder="5">
                <title>Sound Notification End</title>
                <hookname>parse_templates</hookname>
                <phpcode><![CDATA[
                        if(THIS_SCRIPT == 'index' && ($vbulletin->options['affiliation_enabled']))
                        {
                        $vbphrase['powered_by_vbulletin'] .= "<br /><div class=\"smallfont\" align=\"center\">Sound Notification by <a href=\"https://vborg.vbsupport.ru/member.php?u=238957\">TheInsaneManiac</a> of <a href=\"http://www.consolediscussions.com/forum/\">ConsoleDiscussions</a></div>";
                        }]]></phpcode>
        </plugin>
</plugins>
        <phrases>
                <phrasetype name="vBulletin Settings" fieldname="vbsettings">
                <phrase name="setting_sound_notification_enabled_title" username="TheInsaneManiac"><![CDATA[Sound Notification Settings]]></phrase>
                <phrase name="setting_sound_notification_enabled_desc" username="TheInsaneManiac"><![CDATA[Enable Sound Notification?]]></phrase>
                <phrase name="settinggroup_sound_notification" username="TheInsaneManiac"><![CDATA[Sound Notification]]></phrase>
                </phrasetype>
        </phrases>
        <options>
<settinggroup name="sound_notification" displayorder="9999">
        <setting varname="sound_notification_enabled" displayorder="1">
                <datatype>number</datatype>
                <optioncode>yesno</optioncode>
                <defaultvalue>1</defaultvalue>
        </setting>
        </settinggroup>
        </options>
</product>


Boofo 03-23-2011 11:29 PM

What is this?
Code:

<vb:if condition="$bbuserinfo['fieldXX'] === 'No'">

The XX in fieldXX should be a field number. And the === should be ==.

TheInsaneManiac 03-23-2011 11:35 PM

Quote:

Originally Posted by Boofo (Post 2176781)
What is this?
Code:

<vb:if condition="$bbuserinfo['fieldXX'] === 'No'">

The XX in fieldXX should be a field number. And the === should be ==.

As I said, I removed the conditionals completely, because I knew that would come up. Still no code is displayed.

Boofo 03-24-2011 12:45 AM

Try replacing this:
Code:

if ($vbulletin->options['sound_notification_enabled'])
{
        $templater = vB_Template::Create('soundnotification');
        $soundnotification .= $templater->render();
        vB_Template::preRegister('header',array('soundnotification' => $soundnotification));
}


With his:
Code:

if ($vbulletin->options['sound_notification_enabled'])
{
        $templater = vB_Template::Create('soundnotification');
        $template_hook['header_userinfo'] .= $templater->render();
}


TheInsaneManiac 03-24-2011 03:14 AM

I don't want to use hooks though, the whole purpose is to only activate when the user gets a notification.

Boofo 03-24-2011 03:29 AM

You can still use a conditional for the notification.

TheInsaneManiac 03-24-2011 03:58 AM

Is there a conditional for when they have one unread message?


All times are GMT. The time now is 10:35 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.01321 seconds
  • Memory Usage 1,810KB
  • 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
  • (9)bbcode_code_printable
  • (4)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (26)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