View Full Version : Please read if you know ANYTHING about hacking vB!
Ok, i got custom testboxes to load entries into the thread table. its there! But, now what file do I need to edit to load that variable into my postbit template (showthread.php)? I tried $post[variable] but that didn't work? Am I using the wrong variable? or is there a file I need to edit? If I need to edti a file, which one?
Thanks!!
-Sean
g-force2k2
07-05-2002, 01:35 AM
custom texstboxes? can you explain a little more? im not sure i follow ;\
g-force2k2
Ah, ok. :) Like, when you make a new thread, there are textboxes, like Version:. Along with Post subject, etc..
g-force2k2
07-05-2002, 03:00 AM
oh i see what you mean ;) you have to alter the post and thread database to get what you're looking for ;) sorry about that :)
g-force2k2
Oh, so I have to alter BOTH? Hmmm, ok. The only one I have altered now is thread.
g-force2k2
07-05-2002, 03:05 AM
Well it depends on what you're looking to achieve... if you want just something that is on the first post then you use the thread only if not then you have to use both... thats kinda what i meant sorry :)
g-force2k2
Well, actually, I do only want to use it in the first post. :D
So, how do I load the variables on to the first post? What file do I need to edit?
(I already have a hack that makes the first post different from the rest.)
g-force2k2
07-05-2002, 03:21 AM
Okay sorry about that... the file that you have to edit is going to be the newthread.php if its a textbox i'd suggest making a maxlength if you haven't and then for it to store as what you'd like you have to find out where the parts are for updating and inserting into the thread... becauase the variable you add will have to be in both ;) hope that helps
g-force2k2
Ok, I have already made it so newthread.php adds the entry for the textboxes into the thread table. So, what you're saying, is to also modify it so it adds an entry into the POST table also? I tried looking for whhere vB turns everything from the THREAD table into variables, but I can't find it. Does anyone know what file it is? For example, where does vB change the subject from thread, into the subject in the post? :D
Ok, I got it so it loads the entries into both thread and post. But, I still can't get the entries into variables and on to the page!!
They did the same thing here in the hacks forum, how did they load them on to their page???
Anyone?
Anyone?? :( I leave tomorrow, so some help today would be great...
I have tried EVERYTHING.
I have added queries here and there, nothing. moved that query everywhere, nothing... Someone help?? :-\
Can anyone out there help me out?
Still gotten no where. (Of course, I was gone from the 7th til' the 21st. :))
Someone HAS to know!
Come on... Someone please help me.. :-\
Logician
07-30-2002, 08:51 AM
Your message lacks many crucial details:
1- Have you managed to update these new fields you created inside vb? ie. are vb writing your custom variables user entered to your custom db fields when a new post is made? First check that out via PHPmyAdmin, to make sure custom fields are populated.
2- If they are populated what are these fields? In other words, what new fields have you created in which tables? (thread? post? both? which do you populate?)
3- What code are you trying to apply and fail in showthread.php? Where do you insert it in the file? Have your traced the problem by debugging? put some "echo variablename"s around to see if vb can read data from these fields successfully or not..
4- If vb can read data from the new fields, have you made template modifications so that they are displayed in thread view?
It is really impossible for someone to help you without knowing these details (unless he codes the script for you from the ground)..
thanks for your reply, I'll answer to the best i can.
1 & 2. Yes, the fields (named: MAKER, MAKER_MAIL, and MODEL_DL) are populated. I still have to edit the post edit page, but that'seast important. The fields are created at the end of BOTh "POST" and "TABLE" and are both populated when a new post is made.
3. I tried to apply a simple mysql query, and echo'ed right below it, no go. I tried this code in MANY different places in showthread.php, and none worked. Is there a certain place that will?
4. Still haven't gotten the variables to show up on ANY page, always nothing.
Hope that helps some. If you want the exact code I put in the files, I can try to remake, as I don't have it any longer.
thanks
Logician
07-31-2002, 08:17 AM
First of all, IMO it's not a good idea to create these custom fields in BOTH tables. If these fields are thread related (unique in thread), create them in thread table, if they are message related (unique in a message but can be many in a thread) create them in post table.
If it is in thread table and you want to get it from there, you need to edit queries in showthread.php which gets data from thread table. You need to add these custom fields to SELECT queries so that they are got from db too. Here is an example:
$thread=$DB_site->query_first("SELECT threadid FROM thread WHERE forumid IN (0$forumslist) AND visible=1 AND (sticky=1 OR sticky=0) AND lastpost>='".($foruminfo[lastpost]-30)."' AND open<>10 ORDER BY lastpost DESC LIMIT 1");
should be:
$thread=$DB_site->query_first("SELECT threadid, custom1, custom2 FROM thread WHERE forumid IN (0$forumslist) AND visible=1 AND (sticky=1 OR sticky=0) AND lastpost>='".($foruminfo[lastpost]-30)."' AND open<>10 ORDER BY lastpost DESC LIMIT 1");
Now you can use this fields as:
$thread['custom1']
$thread['custom2']
Remember 2 important points:
1- there is not 1 query to change in showthread.php. This file have different queries for different actions, like: when user wants to read the last post, when he wants to read the newest post etc.. You have to go through entire file and modify all relevant SELECT commands that query thread table.
2- After you modify it, use "echo $thread['custom2'];" after the line you changed to make sure, query gets you data correctly. If it does, you can use it in showthread.php. But if you want to use it in postbit, postbit tempalte is parsed inside in admin/functions.php file inside "function getpostbit" and to use your new variables in that function, dont forget to add their name to the global list of the function..
Hope this helps.. :glasses:
Thanks, I will try that out right now! :D
I will also keep the new fields in the thread table only, because they are unqieu to JUST the thread.
Thanks again!
Ok, it works! Now, the part I don't understand. How do I get all this into postbit? I looked in function getpostbit, but I don't know where to start. :-\
I did put this in, is that what you meant by adding it to the global's list?
function getpostbit($post,$templatename) {
// sorts through all the stuff to return the postbit template
// user
global $bbuserinfo,$session,$ignore,$cookietimeout;
// showthread
global $counter,$firstnew,$sigcache,$highlight,$postid,$f orum,$maker,$maker_mail,$model_dl;
// global options
global $showdeficon,$displayemails,$enablepms,$allowsigna tures,$wordwrap,$dateformat,$timeformat,$logip,$re placewords,$postsperday,$avatarenabled,$registered dateformat,$viewattachedimages;
The threee variables are maker, maker_mail, and model_dl. All they need to do is show up in my first post of a thread. I already have a working hack that makes the first post of threads in a certain table its own template, which works fine. Basically, i need the ability to use them in "postbit."
What exactly do I change/add in the function to get maker, maker_mail, and Model_dl available in the "postbit" template?
Thanks! :D
Logician
08-02-2002, 05:59 AM
yes you globalized them correctly. Now to display it in postbit, edit your postbit template and put your custom variables ($maker,$maker_mail,$model_dl) there.
This will display these variables in all posts. If you want to display in only first post try this: in showthread.php, find:
$postbits = '';
$counter=0;
$postdone = array();
$sigcache = array();
while ($post=$DB_site->fetch_array($posts) and $counter++<$perpage) {
if ($postdone[$post[postid]]) {
$counter--;
continue;
} else {
$postdone[$post[postid]]=1;
}
$postbits .= getpostbit($post);
}
Replace it as:
$postbits = '';
$counter=0;
$counter2=0;
$postdone = array();
$sigcache = array();
while ($post=$DB_site->fetch_array($posts) and $counter++<$perpage) {
$counter2++;
if ($counter2!=1)
{
$maker='';
$maker_mail='';
$model_dl='';
}
if ($postdone[$post[postid]]) {
$counter--;
continue;
} else {
$postdone[$post[postid]]=1;
}
$postbits .= getpostbit($post);
}
Looks like version 2.2.6 is different from 2.2.2 (what I'm using). I'm guess that's for 2.2.6? Here's what i have, I think it's pretty much the same?
LINE 406 TO.....
$counter=0;
while ($post=$DB_site->fetch_array($posts) and $counter++<$perpage) {
if ($postdone[$post[postid]]) {
$counter--;
continue;
} else {
$postdone[$post[postid]]=1;
}
$postbits .= getpostbit($post,iif($counter==1 and $pagenumber==1 and $thread['forumid']==41 or $thread['forumid']==42 or $thread['forumid']==44 or $thread['forumid']==45, 'postbit_first', 'postbit'));
}
...418
(I added some code (in bold & Underlined) for my "first post different" hack.)
Here's what I tried:
$counter=0;
$counter2=0;
$postdone = array();
$sigcache = array();
while ($post=$DB_site->fetch_array($posts) and $counter++<$perpage) {
$counter2++;
if ($counter2!=1)
{
$maker='';
$maker_mail='';
$model_dl='';
}
if ($postdone[$post[postid]]) {
$counter--;
continue;
} else {
$postdone[$post[postid]]=1;
}
$postbits .= getpostbit($post,iif($counter==1 and $pagenumber==1 and $thread['forumid']==41 or $thread['forumid']==42 or $thread['forumid']==44 or $thread['forumid']==45, 'postbit_first', 'postbit'));
}
I tried $post[maker] and $maker, and neither worked. Could it be due to the different version (if that was 2.2.6))
Thanks for all the help! :D
Logician
08-04-2002, 03:44 PM
1- Did you use $maker in postbit?
2- Does "echo $maker;" in showthread.php displays your info in debug? You said you can get your variable successfully in showthread.php, so I'm assuming that $maker variable is correctly assigned its value in showthread.php.. You'd better make sure..
Using echo thread['maker']; works in showthread.php.
Where am i suppose to use eacho $maker;?
Don't worry about modifying anything so it only appears in teh first post. All I need to know is how to get the variable into postbit, my template hack will do the rest.
Logician
08-05-2002, 06:06 AM
Using echo thread['maker']; works in showthread.php.
ok then use:
$maker=$thread['maker'];
in showthread.php (after $thread['maker'] is populated and BEFORE function getpostbit is called) and all must be set provided that $maker is put into your postbit template and it's globalized as you confirmed in your previous message.
Thank you sooo much! :D
I think its also possible to get the variables into forumdisplay.php, because these forums do the same thing in the hacks forum.
Do you know how I could do that? This isn't as important, it would just be awesome if I could do it.
Logician
08-05-2002, 02:00 PM
I guess you should modify this section in forumdisplay.php:
$threads=$DB_site->query("
SELECT $dotuserid $votequery ".iif($foruminfo[allowicons],'icon.title as icontitle,icon.iconpath,','')."
thread.threadid,thread.title,lastpost, forumid,pollid,open,replycount,postusername,postus erid,
lastposter,thread.dateline,views,thread.iconid,not es,thread.visible,sticky,votetotal,attach
FROM thread
".iif($foruminfo[allowicons],'LEFT JOIN icon ON (icon.iconid = thread.iconid)','')."
$dotjoin
WHERE $threadids
ORDER BY sticky DESC, $sortfield $sqlsortorder
");
As:
$threads=$DB_site->query("
SELECT $dotuserid $votequery ".iif($foruminfo[allowicons],'icon.title as icontitle,icon.iconpath,','')."
thread.threadid,thread.title,lastpost, forumid,pollid,open,replycount,postusername,postus erid,
lastposter,thread.dateline,views,thread.iconid,not es,thread.visible,sticky,votetotal,attach,thread.Y OURCUSTOMFIELD
FROM thread
".iif($foruminfo[allowicons],'LEFT JOIN icon ON (icon.iconid = thread.iconid)','')."
$dotjoin
WHERE $threadids
ORDER BY sticky DESC, $sortfield $sqlsortorder
");
Then a few lines below right after:
while ($thread=$DB_site->fetch_array($threads)) { // and $counter++<$perpage) {
add
$maker=$thread['YOURCUSTOMFIELD'];
and use $maker in the relevant template..
Not tested, should work... ;)
Thank you!! man, you rock!
Works perfect!
Since you are on such a roll, could you tell me if its possible to get the # of posts - # of threads? (EG: 15 posts, but 10 threads, therefore 5 comments & this would be displaying forums inside a category) I am wondering if its possible so i can show how many comments there are, and how many reviews there are. I tried doing a simple equation in forumdisplay.php, but it didn't seem to do anything. Do you know if its possible? If it is possible, could you tell me where to put the equation? Again, this is not a must, just another thing that would be awesome to do.
Thanks again! :D
Logician
08-05-2002, 04:46 PM
I dont think I understand what you want to do?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.