vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   [cinq's vbArticles v1.0 Hack] - The development process (https://vborg.vbsupport.ru/showthread.php?t=69906)

rake 01-07-2005 10:17 AM

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

cinq 01-07-2005 12:50 PM

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

rake 01-07-2005 01:56 PM

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);

cinq 01-07-2005 01:58 PM

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.

rake 01-07-2005 02:00 PM

No problem. I'm glad i am able to help. Just post if you need more advice. :)

cinq 01-07-2005 02:06 PM

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 ! :D:D:D:D

rake 01-07-2005 03:08 PM

I just realised this: that AND should actually be OR

cinq 01-08-2005 03:02 AM

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 :)

cinq 01-08-2005 03:04 AM

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

cinq 01-08-2005 03:07 AM

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


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 ? :)


All times are GMT. The time now is 11:17 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.01064 seconds
  • Memory Usage 1,774KB
  • 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
  • (3)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete