vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   iam stuck with my modification (https://vborg.vbsupport.ru/showthread.php?t=61946)

MrNase 02-26-2004 01:54 PM

iam stuck with my modification
 
hey, i hope i got the right forum for my little 'request'. :)

I have added a new column called 'onfrontpage' to the 'thread' table.
When i make a new thread there's a little selectbox where i can choose something like "is on frontpage". When i select "yes" the column 'onfrontpage' for this thread is filled with '1'. Otherwise it's '0'.

Now here's my problem:

I wan't to have a little '<input type="checkbox">' on showthread.php that shows if this thread is currently on the frontpage (if the columns 'onfrontpage' says '1') so that i can easily change it.

But how do i do that? I've been working on that for 4 hours now but i didn't figure out how to do that yet :(

I can't select the value of 'onfrontpage' out of the database.

It must be somewhere hidden in the showthread.php or functions_showthread.php.

Is there someone with too much spare time who is willing to help me?
It doesn't need to be a detailed instruction, some hints are more than welcome :)

regards,
dominik

vbmechanic 02-26-2004 02:08 PM

I believe it should be automatically loaded with your thread cache... Check $threadinfo['onfrontpage'] and see if it holds your variable?

MrNase 02-26-2004 02:53 PM

Well, that did the trick. I deleted that and replaced it with $show[onfrontpage] and that didn't work :(
Thanks alot :)

my next problem:

i added the following to the SHOWTHREAD-template
Code:

<div><label for="cb_onfrontpage"><input type="checkbox" name="do" value="onfrontpage" id="cb_onfrontpage" tabindex="1" $checked[onfrontpage] />Auf der Startseite?</label></div>
and the following to options.php:
Code:

// ############################### start do set on frontpage ###############################
 if ($_POST['do'] == 'onfrontpage')
 {
        $DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET onfrontpage = $threadinfo[onfrontpage] WHERE threadid = $threadid");
 
        $_REQUEST['forceredirect'] = 1;
        $url = "showthread.php?$session[sessionurl]t=$threadid";
        eval(print_standard_redirect('redirect_openclose'));
 
 }

But it doesn't change the value in the database :(

If i change $threadinfo[onfrontpage] to '1' or '0' manually he'll change it in the database... wrong variable i try to use?

vbmechanic 02-26-2004 03:03 PM

In your query:

"onfrontpage = $threadinfo[onfrontpage]"

You don't want to set the onfrontpage to the $threadinfo value, you want to set it to the form value. I would replace the checkbox value with "1" so that it will feed the database a 1 if it is checked.

MrNase 02-26-2004 03:07 PM

I changed it to
Code:

<div><label for="cb_onfrontpage"><input type="checkbox" name="onfrontpage" value="1" id="cb_onfrontpage" tabindex="1" $checked[onfrontpage] />Auf der Startseite?</label></div>
but there must be a problem with 'name="onfrontpage"' :(

vbmechanic 02-26-2004 03:13 PM

Try these:

Code:

<div><label for="cb_onfrontpage"><input type="checkbox" name="onfrontpage" value="1" id="cb_onfrontpage" tabindex="1" $checked[onfrontpage] />Auf der Startseite?</label></div>
and

Code:

// ############################### start do set on frontpage ###############################
 if ($_POST['onfrontpage'] == 1)
 {
        $DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET onfrontpage = 1 WHERE threadid = $threadid");
 
        $_REQUEST['forceredirect'] = 1;
        $url = "showthread.php?$session[sessionurl]t=$threadid";
        eval(print_standard_redirect('redirect_openclose'));
 
 }


MrNase 02-26-2004 03:23 PM

hm that would work but not as i expected.
How can i set onfrontpage to '0' ?
I want it so that you can select with the checkbox if the the post is on the frontpage (onfrontpage = '1') or not (onfrontpage = '0').

With your code it can only set it to '1' but not to '0'.

vbmechanic 02-26-2004 03:27 PM

Well I don't know where this code is going, so I don't know if it has access to a current $threadinfo... if it does, this would work:

Code:

// ############################### start do set on frontpage ###############################
 if ($_POST['onfrontpage'] != $threadinfo['onfrontpage'])
 {
        $DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET onfrontpage = $_POST['onfrontpage'] WHERE threadid = $threadid");
 
        $_REQUEST['forceredirect'] = 1;
        $url = "showthread.php?$session[sessionurl]t=$threadid";
        eval(print_standard_redirect('redirect_openclose'));
 
 }


MrNase 02-26-2004 03:36 PM

this code is going to options.php line 143 :)

vbmechanic 02-26-2004 03:45 PM

do you mean postings.php? If so, it should have threadinfo and that should work.

MrNase 02-26-2004 04:12 PM

I think i got it...
Code:

// ############################### start do set on frontpage ###############################


 if ($_POST['onfrontpage'] != $threadinfo['onfrontpage'])
 {
        if($threadinfo['onfrontpage'] == '1') {
                $value = '0';
        }
        else {
                $value = '1';
        }
       
        $DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET onfrontpage = $value WHERE threadid = $threadid");
 
        $_REQUEST['forceredirect'] = 1;
        $url = "showthread.php?$session[sessionurl]t=$threadid";
        eval(print_standard_redirect('redirect_openclose'));
 
 }


vbmechanic 02-26-2004 04:25 PM

Ah yup, make the value 0 instead of blank.. congrats :D

MrNase 02-26-2004 05:12 PM

thank you man, you are my hero ;)

One last thing but i think i can figure that out on my own.
The thread tools always has "close thread" or "open thread" as a default. (because it's a radio button) That means if i select 'to frontpage' it automatically selects 'close' or 'open' and that's quite annoying :D

MrNase 02-27-2004 01:15 PM

One last thing: I try to get the first post of each thread marked with "onfrontpage" out of the database. Iam using the following query but i doesn't work :(

Code:

$getnews = $DB_site->query("
        ## GET LATEST THREADS ##
        SELECT thread.*,thread.iconid AS threadiconid $previewfield
        FROM ".TABLE_PREFIX."thread AS thread
        LEFT JOIN ".TABLE_PREFIX."deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND type = 'thread')
        LEFT JOIN ".TABLE_PREFIX."post AS post ON(thread.threadid = post.threadid)
        $previewjoin
        WHERE open = '1'
        AND forumid NOT IN (0$limitfids)
        AND onfrontpage = '1'
        AND thread.visible = '1'
        AND deletionlog.primaryid IS NULL
        ORDER BY lastpost
        DESC LIMIT 10");

while($news = $DB_site->fetch_array($getnews)) {

The errormessage is
Code:

Database error in vBulletin 3.0.0 Release Candidate 4:

Invalid SQL:
        ## GET LATEST THREADS ##
        SELECT thread.*,thread.iconid AS threadiconid , post.pagetext AS preview
        FROM thread AS thread
        LEFT JOIN deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND type = 'thread')
        LEFT JOIN post AS post ON(thread.threadid = post.threadid)
        LEFT JOIN post AS post ON(post.postid = thread.firstpostid)
        WHERE open = '1'
        AND forumid NOT IN (0)
        AND onfrontpage = '1'
        AND thread.visible = '1'
        AND deletionlog.primaryid IS NULL
        ORDER BY lastpost
        DESC LIMIT 10
mysql error: Not unique table/alias: 'post'

mysql error number: 1066

Date: Friday 27th of February 2004 04:20:26 PM
Script: http://xxx/232/new.php
Referer:
Username: MrNase
IP Address: xx.xxx.0.xx


Andreas 02-27-2004 01:54 PM

Quote:

Originally Posted by MrNase
Code:

LEFT JOIN post AS post ON(thread.threadid = post.threadid)
LEFT JOIN post AS post ON(post.postid = thread.firstpostid)


That's the problem - you can't use the alias post twice.
I guess the second left join comes form $previewjoin.


All times are GMT. The time now is 01:14 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.02783 seconds
  • Memory Usage 1,761KB
  • 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
  • (10)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (15)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