Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-30-2010, 03:12 PM
gruftiradio gruftiradio is offline
 
Join Date: Dec 2009
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Database work

Hi,

I'm new at creating a vB4 mod.
I need to know, how I can work with the Database in templates. I have created a template, correctly with the forum Design. I want to read out the ucash field and an own Table. Can I do this with templates? I don't know how to create a php file, with the forum Design...

Greetings,
Andreas
Reply With Quote
  #2  
Old 05-01-2010, 04:50 PM
bpr bpr is offline
 
Join Date: Dec 2009
Location: London
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi Andreas,

yeah the beginning is a difficult one thats for shure... 1 weeks ago i had the same problem, firstly i suggest you to read the following articles here on the board:

Creating an own vbulletin site and getting in touch with the very few basics, but you will also see how it works with the template
https://vborg.vbsupport.ru/showthread.php?t=228112


bascially if you want to show the website you can create a new template and put this code inside:

Code:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <head>
    <title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
    {vb:raw headinclude}
    {vb:raw headinclude_bottom}
  </head>
  <body>
    
    {vb:raw header}
    
    {vb:raw navbar}
    
    <div id="pagetitle">
      <h1>{vb:raw pagetitle}</h1>
    </div>
    
    <h2 class="blockhead">THIS IS AN EXTRA PART FOR YOU TO ECHO A HEADLINE</h2>
    <div class="blockbody">
      <div class="blockrow">
        YOU CAN WRITE HERE YOU MAIN TEXT, BUT YOU DONT HAVE TO USE IT
      </div>
    </div>
    
    {vb:raw footer}
  </body>
</html>
You have to register the variable "{vb:raw pagetitle}" before you render the template, but thats also explained in the article.

The next one you should propably read is this one:
https://vborg.vbsupport.ru/showthread.php?t=231525

It will help you how conditionals work and read the red line, it is really important : )

After that, I suggest you to read:
http://ragtek.org/blog/vbulletin/vbu...asse-benutzen/
if you cant understand german you can translate it on the right hand side, but actually your name sounds german anyway you should be a bit carefull in some cases "vB::$vbulletin->" doesnt work, what you can simply do is removing the "vB::" and having just
"$vbulletin->etc...."

In case you want to exclude some of your codes into another php file in the folder "/includes" you gotta use "global $vbulletin" otherwise you cant use those things in an external file and it would cause a blank site


i hope that gave u a base to build up on.... keep asking and sometimes http://members.vbulletin.com/api/ also helps : )

all the best
Reply With Quote
  #3  
Old 05-01-2010, 05:32 PM
gruftiradio gruftiradio is offline
 
Join Date: Dec 2009
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

much thanks for the help!
Yes, I'm german. So sorry for my bad english

I made it like this way, yesterday:
I added a custom Template, wich renders me the site in the forumdesign.
Then I added an iframe to the template, in the area of the main site. So I can use my own php Page. I know php good enough to do all, I want.

Only Problem is, I don't know how to create an ACP Menu ore how I can add Phrases to the php File. So all is hardcoded. This is ok for me, but I wanted to publish the AddOn (SMS send Service, with some Options for registered members, guests and to use ucash) at vbullrtin-germany.org. I think, hardcoding is bad for this...

Greetings,
Andy
Reply With Quote
  #4  
Old 05-01-2010, 05:57 PM
bpr bpr is offline
 
Join Date: Dec 2009
Location: London
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, I am not that deep into that acp stuff as well, cant help you with that one.
But you dont have to put phrases in the php file ? - To be honest i am not certain about that, but it is enough to put them in the template therefor you could use

{vbhrase phrasename}

for a phrase which doesnt include html or you could that one
{vb:rawphrase phrasename}

the second one will allow you to use html in your phrase.

btw: german as well, but fair play for the others, may it help somebody else on this english speaking board : )
Reply With Quote
  #5  
Old 05-01-2010, 06:11 PM
gruftiradio gruftiradio is offline
 
Join Date: Dec 2009
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The Problem is, in my php file, I mixed some echo statements with php code. So I can't use phrases in the Template, I need them in PHP. Ore dit I understand it wrong?

Ok, when the AddOn is ready, I will publish it on both sides. Even here. Of course, for free.
Some time ago, I searched for an AddOn like this, without much response. That's why I decidet to code it by myself, hoping that I learn fast.
Somenody who knows a little bit of php/html, can use every SMS Gateway, wich provides a http gateway. I think, that is very useful. Even in connection with ucash, it can make the users more activ.
Reply With Quote
  #6  
Old 05-01-2010, 07:17 PM
bpr bpr is offline
 
Join Date: Dec 2009
Location: London
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you have some example code ? And why do you have echos ? May you should replace echos with registering variables ?
Reply With Quote
  #7  
Old 05-01-2010, 07:28 PM
gruftiradio gruftiradio is offline
 
Join Date: Dec 2009
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't know, how registering Variables work...

Some example Code:
PHP Code:
$abfrage "SELECT * FROM sms WHERE uID = $userID";
$ergebnis mysql_query($abfrage);
$x 0;
while(
$row mysql_fetch_object($ergebnis))
   {
    
$x $x 1;
   }
$sent $x;
$x $sent;

echo 
"Du hast noch <b>$x</b> Kostenlose SMS f&uuml;r heute &uuml;brig.<br>"
Sorry for the german. I hope you can translate it. I have many like this. That would be much Variables...
Reply With Quote
  #8  
Old 05-01-2010, 08:00 PM
bpr bpr is offline
 
Join Date: Dec 2009
Location: London
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here is a short guide how to register vars
https://vborg.vbsupport.ru/showthread.php?t=228078

this should help you.

basically it looks like that all the time:
PHP Code:
/* render template and register variables */
$templater vB_Template::create('mytemplate');
    
$templater->register('my_var'$my_var);
    
$templater->register('my_array'$my_array);
$templater->render(); 
in that case i mentioned you could edit the template "mytemplate" which you can easily create by click: ACP -> Styles und Templates -> Styles Verwalten -> Neues Template hinzufuegen

it has to have the name mytemplate, after that you can put anykind of html inside the code box, however, you could also use "my_var" as well as "my_array" in that template, because you were registering for that specific template those two vars...
if you want to print for example "my_var" you simply write {vb:raw my_var} and with the array you could do it like this: {vb:raw my_array.key} (.key represents for example, id, titel, description or whatever else : )

my small explanation doesnt mean, that you should not read that article : )

have fun
Reply With Quote
  #9  
Old 05-01-2010, 08:30 PM
gruftiradio gruftiradio is offline
 
Join Date: Dec 2009
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, I'm really happy for your help!

I read the article tomorrow and then try a little bit around, even with your examples.
Today, it is midnight, here in Germany. So I can concentrate better tomorrow.

Rhank you very much!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:43 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.04105 seconds
  • Memory Usage 2,248KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete