Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #31  
Old 01-07-2005, 10:17 AM
rake's Avatar
rake rake is offline
 
Join Date: Nov 2002
Posts: 311
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
// only get subcats
$cats $DB_site->query("SELECT * FROM cats WHERE parent <> 0");
while(
$cat $DB_site->fetch_array($cats))
{
  
$cat_cache["$cat[parentid]"]["$cat[order]"] = $cat;
}

// only get parents
$parents $DB_site->query("SELECT * FROM cats WHERE parent=0");
while(
$parent $DB_site->fetch_array($parents))
{
     foreach(
$cat_cache as $pr)
     {
          foreach(
$pr as $order => $subcat)
          {

                 eval 
here
          
}
       }


Might be some errors in there, but you get the idea of how it should work. Just 2 queries.
Reply With Quote
  #32  
Old 01-07-2005, 12:50 PM
cinq's Avatar
cinq cinq is offline
 
Join Date: Oct 2002
Posts: 1,398
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

With regards to the Similar Articles issue, this is what I have got now, but it is giving me a big headache :

PHP Code:
$similarlist explode(" "$title);
        
$countsimiliar sizeof($similarlist);

        for(
$j 0$j $countsimiliar$j++)
        {
            
$nochars strlen(''.$similarlist[$j].'');
            if(
$nochars 4)
            {
                
$similarquery2 .= "title LIKE '%".$similarlist[$j]."%' OR content LIKE '%".$similarlist[$j]."%' ";
                if (
$j $countsimiliar-1)
                {
                    
$similarquery2 .= " AND ";
                }
                
$markyes =1;
            }
        }

        if(
$markyes==1)
        {
            
$similarquery "SELECT * FROM " TABLE_PREFIX "articles_article WHERE ";
        }
        
$similarquery $similarquery.$similarquery2
It works fine if the last word in the title has more number of characters than the limit, which is set by $nochars>4 in this case.
But if not, an extra AND will be appended to the query.....

so for e.g, a title like "Review of the Nvidia Nforce Chip"
That would fail, since the last word Chip consists of only 4 characters.

how could I go about this ?

So close yet so far...
My head is spinning .....
Reply With Quote
  #33  
Old 01-07-2005, 01:56 PM
rake's Avatar
rake rake is offline
 
Join Date: Nov 2002
Posts: 311
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here i am again to offer the solution..

remove this if entirely:
if ($j < $countsimiliar-1)

and add the and argument after each call condition.

then, just before
$similarquery = $similarquery.$similarquery2;

add

$similarquery2 = substr($similarquery2, 0, -4);
Reply With Quote
  #34  
Old 01-07-2005, 01:58 PM
cinq's Avatar
cinq cinq is offline
 
Join Date: Oct 2002
Posts: 1,398
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I really appreciate your help rake , really sorry I need to impose on you.
[high]* cinq worships rake
[/high]

I will try that code in post 34 soon.
Reply With Quote
  #35  
Old 01-07-2005, 02:00 PM
rake's Avatar
rake rake is offline
 
Join Date: Nov 2002
Posts: 311
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No problem. I'm glad i am able to help. Just post if you need more advice.
Reply With Quote
  #36  
Old 01-07-2005, 02:06 PM
cinq's Avatar
cinq cinq is offline
 
Join Date: Oct 2002
Posts: 1,398
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by rake
Here i am again to offer the solution..

remove this if entirely:
if ($j < $countsimiliar-1)

and add the and argument after each call condition.

then, just before
$similarquery = $similarquery.$similarquery2;

add

$similarquery2 = substr($similarquery2, 0, -4);
Problem Number One Implemented ! - (thanks to rake)
It works !
Reply With Quote
  #37  
Old 01-07-2005, 03:08 PM
rake's Avatar
rake rake is offline
 
Join Date: Nov 2002
Posts: 311
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I just realised this: that AND should actually be OR
Reply With Quote
  #38  
Old 01-08-2005, 03:02 AM
cinq's Avatar
cinq cinq is offline
 
Join Date: Oct 2002
Posts: 1,398
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nathanaus
Maybe this isn't really appropriate (I'm new forgive me) but what would be nice to see in it:

1. Ability to give reputation points to an article author.

2. There is a hack here to gie award to posts, could something similar be done that if an article is well written there is an option for the admin to give an "award" with associated image that sticks to the article indicating that it won an award for "good article writing" or soemthing?

Hi nathan
I am sorry but I do not intend to make those 2 features you suggested default for this hack.

But in the future, they may come as add-ons to this hack.

As it is, I hope to wrap up the current feature set I have in mind and push it out for beta testing
Reply With Quote
  #39  
Old 01-08-2005, 03:04 AM
cinq's Avatar
cinq cinq is offline
 
Join Date: Oct 2002
Posts: 1,398
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by oly51
Right. I was referring to a thumbnail in the article proper. Say someone was writing a 'how-To' article. In the article, they put a text paragraph and in the next paragraph, they put a thumbnail that shows what the text in that paragraph is describing. The thumb would be on the left (or right) and the text would go to the side and under the thumb.

Sorry for not being clear.
I guess you mean adding images to the article content.
Actually, that's where I am trying to add a WYSIWYG editor to the add article page ( which should only be accessible to the admin for now because it should allow uploads of the image ).

However I have yet to find a suitable textarea replacement, as mentioned on the first few posts of this thread.
I have just found that SPAW actually accepts dynamic image libraries which can be put to use but then, I cannot seem to get it to work ( the includes ) on my localhost...
Reply With Quote
  #40  
Old 01-08-2005, 03:07 AM
cinq's Avatar
cinq cinq is offline
 
Join Date: Oct 2002
Posts: 1,398
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by rake
PHP Code:
// only get subcats
$cats $DB_site->query("SELECT * FROM cats WHERE parent <> 0");
while(
$cat $DB_site->fetch_array($cats))
{
  
$cat_cache["$cat[parentid]"]["$cat[order]"] = $cat;
}

// only get parents
$parents $DB_site->query("SELECT * FROM cats WHERE parent=0");
while(
$parent $DB_site->fetch_array($parents))
{
     foreach(
$cat_cache as $pr)
     {
          foreach(
$pr as $order => $subcat)
          {

                 eval 
here
          
}
       }


Might be some errors in there, but you get the idea of how it should work. Just 2 queries.

Sorry rake, but I don't quite get your code ... ( noob here )

but your solution could potentially teach me how to deal with handling queries in nested while loops ( which I keep using now ..... )

could you take the time to explain this to me, please ?
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 06:22 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.02359 seconds
  • Memory Usage 2,310KB
  • Queries Executed 14 (?)
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
  • (3)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete