vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Database work (https://vborg.vbsupport.ru/showthread.php?t=241577)

gruftiradio 04-30-2010 03:12 PM

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

bpr 05-01-2010 04:50 PM

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

gruftiradio 05-01-2010 05:32 PM

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

bpr 05-01-2010 05:57 PM

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

{vb:phrase 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 : )

gruftiradio 05-01-2010 06:11 PM

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.

bpr 05-01-2010 07:17 PM

Do you have some example code ? And why do you have echos ? May you should replace echos with registering variables ?

gruftiradio 05-01-2010 07:28 PM

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...

bpr 05-01-2010 08:00 PM

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

gruftiradio 05-01-2010 08:30 PM

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!


All times are GMT. The time now is 06:51 AM.

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.02532 seconds
  • Memory Usage 1,747KB
  • 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_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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