Log in

View Full Version : [cinq's vbArticles v1.0 Hack] - The development process


cinq
09-27-2004, 12:15 AM
BACKGROUND

Would be having some free time in about a month's time ( vacation wheee... ) so I have decided to take up the task of upgrading my previous hack for vb2 to be used in vb3.

A little background of the hack. I initially based the code off Arunan's popular link directory hack. But after a while I ended up changing most of the code to suit my needs. Several versions were pushed each time with more features added and bugs fixed, with help and suggestions from the community ( you folks know who you are :) ).
However, after a while, the hack kind of died a natural death, due to my lack of free time, an uncooperative computer, and actions of some of the members here.

I know there are already other vb3-based hacks around that has the same idea, a hack to house articles/tuts/reviews and what not, both free and paid work.

In any case, I would like to seek suggestions on what would be nice features in such a hack.

The old hack can be seen here : [vB 2.3.x] - vbArticles v0.4 -- For your repository of Articles/Tutorials/FAQs etc.. (https://vborg.vbsupport.ru/showthread.php?t=54331)

All suggestions would be seriously considered and implemented, if it is within my means. I am still a noob compared to many here ! :D
Thanks folks :D


CURRENT PROGRESS STATUS
The current status of the work completed is approximately 90% at this point of time, based on the initial features planned for this hack.
LEFT : install script, query and code optimization.


SCREENSHOTS
You can refer to the following posts for the attached screenshots of what this hack looks like. Note however that the end release may see some/many visual changes.

Post 1 : Initial screenshots (https://vborg.vbsupport.ru/showpost.php?p=584170&postcount=6)
Post 2 : Updated admin interface (https://vborg.vbsupport.ru/showpost.php?p=589831&postcount=13)
Post 3: Updated frontend page (https://vborg.vbsupport.ru/showpost.php?p=589832&postcount=14)


CONTRIBUTING TO THIS HACK
I am sure many require such a hack for their sites, be it for articles, reviews, guides, tutorials and what not. Help me in the development of this hack and allow me to present this hack to you faster and with much better functionality and user-friendliness.

How you can help :

Provide suggestions on new features
Volunteer to run extensive tests on this hack, when early releases become available (PM me for this)
Volunteer to write a comprehensive install (and uninstall) script which would handle database changes, phrases and settings addition, and if possible a page which lists nicely the file changes which are required. (PM me for this)
Provide solutions to problems I encounter along the way (due to my limited knowledge of coding :(). Any problems or questions which are stumping me, I will post in this thread for the community to hopefully render help. These problems will be indexed in this post too, with a prefix as to whether it has been overcome or not.
Create nifty and cool looking graphics for packaging together with this hack's final release. (PM me for this)
....



PROBLEMS REQUIRING ASSISTANCE
Please reference the problem number ( eg. 1 or 2 ... ) when replying to any of these listed problems.

[Suggestions required] Similar Articles feature (https://vborg.vbsupport.ru/showpost.php?p=590222&postcount=16) - [Implemented, thanks to rake] (https://vborg.vbsupport.ru/showpost.php?p=591461&postcount=34)
[Coding help required] Previous/Next Article feature (https://vborg.vbsupport.ru/showpost.php?p=590228&postcount=17) - [Solved, thanks to rake] (https://vborg.vbsupport.ru/showpost.php?p=590683&postcount=23)
[Coding help required] Query Optimization for Category/SubCategory Displaying (https://vborg.vbsupport.ru/showpost.php?p=591343&postcount=28)



POSSIBLE FUTURE FEATURES


Uploading of support zip file for an article
Article submission / with validation
Custom article fields creation
Setting up access/add article/comment/rate by usergroup permissions
ModCP panel to admin articles
Discussion tie-in with a forum thread in a specific 'article discussion' forum




OTHER STUFF

Any other matters, please feel free to post them in this thread as well, and I will address them as soon as I have the time.
Thank you for all help rendered :D

Jolten
09-27-2004, 05:15 AM
oooo I need a good tutorial system. I'd love a good systemthat included the ability to add images both on the main category page and within the contest pages.

+d-cipher
09-30-2004, 03:42 AM
I rarely post, but I'd like to throw in a few suggestions/ideas.

1. Pagination. I am no PHP coder, and I hear that pagination is a pain to code, but it would be nice to have articles/reviews/whatnot have the ability to span several pages.

2. The ability to setup the Articles index page in columns and rows. Admin preference of course.

Example:


Article Category 1 | Article Category 2
Article Category 3 | Article Category 4


3. Article category images. It would be nice to be able to set an image for article categories without relying on/modifying other hacks made for other stuff.

4. Able to set Moderators/Columnists whatever.

5. The option for threaded article/review comments. Something like how slashdot does their user comments would be a nice option, it would be nice to have something visually different from the main forums, yet still integrated.

6. An easy way to add customfields for posting articles. It would make things easier for people submitting articles and columnists to fill out the main article info, then just fill in a few boxes of important stuff like article source, additional links etc. It would also make everything look as uniform as possible.

There is a few. Good luck with the coding, I look forward to testing it out when it becomes available.

nexialys
09-30-2004, 04:18 AM
1- pagination is a 3 lines code... already have something inside vB for that.
2- this is skin related... easy and vB have a hack for the forumhome you can add to the articles system
3- add a field in the category table to do so.. easy
4- this is a bit complicated.. or long at least...
5- can be done with the same system as vB itself
6- this is the most requested feature.
...

cinq
12-20-2004, 03:14 AM
I already have a commercial one for my personal site integrated into an article system I have for vb3.

However I am looking for a free one that I can integrate so as to be able to release my hack here.

I require the following features most importantly :
- image upload management .... able to read the a specific directory and/or subdirectories under the main directory.

I am aware of Spaw (http://www.solmetra.com/en/disp.php/en_products/en_spaw/en_spaw_about) but unfortunately, it does not have this support.

cinq
12-20-2004, 03:21 AM
Some screenshots of what I got going now.

Note the last screenshot, the editor in place.
I need something for that.

cinq
12-21-2004, 09:05 AM
Found a few more ...

HTMLArea (http://www.codeproject.com/jscript/htmlarea.asp)
- no image upload function though

TextArearich (http://www.textarearich.com/features.php)
- no image upload function though

:(

sabret00the
12-21-2004, 10:06 AM
can't you write the image upload system?

and regarding WYSIWYG can't you use the vBulletin one?

cinq
12-21-2004, 11:12 AM
can't you write the image upload system?

I would....if i could :p


and regarding WYSIWYG can't you use the vBulletin one?
Not enough features that would be almost indispensible in article content creation.

HiDeo
12-21-2004, 04:15 PM
Yes you can use the wysiwyg of vbulletin !

Use the "construct_edit_toolbar" fonction ;)

cinq
12-22-2004, 12:45 AM
thks HiDeo :)

infiniterb
12-30-2004, 09:13 PM
Looking good. There's a dire need for a good articles system.

cinq
01-04-2005, 01:11 PM
Well, some screenshots on my progress.

Backend :

1: options galore ( 3/4 of the list shown with more expected )
2: articles management ( featured/orphaned/draft )
3: view all articles ( plus search for article )
4: adding an article ( wysiwyg is my paid script though )
5: category manager
6: adding category ( with category icon disabled - can be toggled at vboptions )

cinq
01-04-2005, 01:15 PM
Some front end shots :

7: Main article home page
8: article view

cinq
01-04-2005, 01:25 PM
I rarely post, but I'd like to throw in a few suggestions/ideas....

Thanks for the feedback, +d-cipher :)

1. Pagination is in place, with options to set the delimiting field ( for article content to break into pages ) as well as number of articles shown per category before breaking into pages too.

2. Not going to do that. Can be changed through templates though.

3. Article images and category images implemented. Category images are an option ( can be toggled on or off )

4. Plan to set access/add article/comment/rate by usergroup permissions. Not done yet but something I will add.

5. I don't plan to do this. I think linear rows is still neater. Also comments can be limited in number ( in options ) to restrict number shown in an article before a link to click to view all is shown.

6. I would like this too. But I have no idea where to begin, in order to allow for custom fields. Any tips, anyone ?

cinq
01-05-2005, 04:39 AM
Problem Number 1

I would like a similar articles feature as part of this hack.
This means that, when viewing an article, at the bottom of the page, there should list the titles ( with links of course ) of articles which have similar content to what you are currently reading.

There are a couple of ways to implement this.
These are some of the ways I thought of :


- When adding/editting an article in the AdminCP, you manually select all related articles via a multiple dropdown list. However, this presents a problem. Going through a long list of articles just to select a couple of related ones is not easy.

- Let the system auto search for related articles.

use the title of the current article you are reading to provide the search keywords to search the title and contents of all other articles in the database. A problem with this is that common words in the current article ( eg. of, in etc. ) get searched too and may turn up too many irrelevant results.
enter keywords when adding/editting articles, and these keywords would be used as the search keywords to search the title and contents of all other articles in the database.


Are there any other suggestions as to how this feature can be implemented ? :)

cinq
01-05-2005, 04:58 AM
Problem Number 2

I implemented a 'Previous article Next article' feature at the top of each article page which provides an easy means to quickly navigate to another article.

This is the code currently in place:

# previous and next article links
$nextone = $artid+1;
$chknextonequery = $DB_site->query("SELECT articles_articleid FROM " . TABLE_PREFIX . "articles_article WHERE articles_articleid=$nextone");
if($DB_site->num_rows($chknextonequery)>0)
{
$nextarticle = 1;
}
else
{
$nextarticle = 0;
}

$previousone = $artid-1;
$chkpreonequery = $DB_site->query("SELECT articles_articleid FROM " . TABLE_PREFIX . "articles_article WHERE articles_articleid=$previousone");
if($DB_site->num_rows($chkpreonequery)>0)
{
$prearticle = 1;
}
else
{
$prearticle = 0;
}


The template where it appears :

<span class="smallfont" style="float:$stylevar[right]">
<if condition="$prearticle==1">
<a href="articles.php?$session[sessionurl]action=viewarticle&artid=$previousone">< Previous Article</a></if>
<if condition="$nextarticle==1 && $prearticle==1">
&nbsp;&nbsp;|&nbsp;&nbsp;
</if>
<if condition="$nextarticle==1">
<a href="articles.php?$session[sessionurl]action=viewarticle&artid=$nextone">Next Article ></a></if>
</span>


Now this code works fine, BUT it assumes that all the rows in the database for articles are present in running order. eg. articleid=1,2,3,4....,100.. It presents a problem when there is a missing articleid in between. for eg. articleid=1,2,3,5,8,10,...,100...

How can I change things to make this work ?
Also if possible combine queries ?

rake
01-05-2005, 06:52 AM
Problem Number 1

I would like a similar articles feature as part of this hack.
This means that, when viewing an article, at the bottom of the page, there should list the titles ( with links of course ) of articles which have similar content to what you are currently reading.

There are a couple of ways to implement this.
These are some of the ways I thought of :


- When adding/editting an article in the AdminCP, you manually select all related articles via a multiple dropdown list. However, this presents a problem. Going through a long list of articles just to select a couple of related ones is not easy.

- Let the system auto search for related articles.

use the title of the current article you are reading to provide the search keywords to search the title and contents of all other articles in the database. A problem with this is that common words in the current article ( eg. of, in etc. ) get searched too and may turn up too many irrelevant results.
enter keywords when adding/editting articles, and these keywords would be used as the search keywords to search the title and contents of all other articles in the database.


Are there any other suggestions as to how this feature can be implemented ? :)

For mysql 3 users: Research the LIKE syntax and find a way to implement it (for example: split thread title into individual words, filter out words that consist of less than 4 characters, then loop through the remaining words and make a list of conditions: OR title LIKE '%$word%' )

For mysql 4 users: Research the MATCH ... AGAINST syntax and you're all set.

And, if you really want to take it to the next level, there was a function that could produce equally sounding words, so you could even search for miswritten words. How cool is that? You should look that up, i forgot it's name..

rake
01-05-2005, 06:57 AM
Problem Number 2

I implemented a 'Previous article Next article' feature at the top of each article page which provides an easy means to quickly navigate to another article.

This is the code currently in place:

# previous and next article links
$nextone = $artid+1;
$chknextonequery = $DB_site->query("SELECT articles_articleid FROM " . TABLE_PREFIX . "articles_article WHERE articles_articleid=$nextone");
if($DB_site->num_rows($chknextonequery)>0)
{
$nextarticle = 1;
}
else
{
$nextarticle = 0;
}

$previousone = $artid-1;
$chkpreonequery = $DB_site->query("SELECT articles_articleid FROM " . TABLE_PREFIX . "articles_article WHERE articles_articleid=$previousone");
if($DB_site->num_rows($chkpreonequery)>0)
{
$prearticle = 1;
}
else
{
$prearticle = 0;
}


The template where it appears :

<span class="smallfont" style="float:$stylevar[right]">
<if condition="$prearticle==1">
<a href="articles.php?$session[sessionurl]action=viewarticle&artid=$previousone">< Previous Article</a></if>
<if condition="$nextarticle==1 && $prearticle==1">
&nbsp;&nbsp;|&nbsp;&nbsp;
</if>
<if condition="$nextarticle==1">
<a href="articles.php?$session[sessionurl]action=viewarticle&artid=$nextone">Next Article ></a></if>
</span>


Now this code works fine, BUT it assumes that all the rows in the database for articles are present in running order. eg. articleid=1,2,3,4....,100.. It presents a problem when there is a missing articleid in between. for eg. articleid=1,2,3,5,8,10,...,100...

How can I change things to make this work ?
Also if possible combine queries ?

if($next = $DB_site->query_first("SELECT whatever FROM table WHERE articles_articleid > $artid ORDER BY artid ASC"))
{
$nextarticle = 1;
}

if($previous = $DB_site->query_first("SELECT whatever FROM table WHERE articles_articleid < $artid ORDER BY artid DESC"))
{
$prearticle = 1;
}


TADA! :D

cinq
01-05-2005, 03:10 PM
if($next = $DB_site->query_first("SELECT whatever FROM table WHERE articles_articleid > $artid ORDER BY artid ASC"))
{
$nextarticle = 1;
}

if($previous = $DB_site->query_first("SELECT whatever FROM table WHERE articles_articleid < $artid ORDER BY artid DESC"))
{
$prearticle = 1;
}




Doesn't seem to do the job, rake :(

rake
01-05-2005, 03:21 PM
ooops... ORDER BY articles_articleid

j_86
01-05-2005, 04:58 PM
I'm soooo looking forward to this!

I have this feature list to suggest;

1) List of article contributers (and auto link to their profile on the forum, if it exists)
2) List of "sources" of information borrowed from someonewhere else for purposes of the article
3) A ModCP panel to admin articles
4) An "edit log" shown on the side of the article front end; edits to the article can be optionaly given a reason for editing by the user, maybe with some predefined reasons such as "Language Error"

cinq
01-06-2005, 01:57 AM
Problem 2 solved ! ( thanks Rake ! )

Code used :

# previous and next article links
if($nextone = $DB_site->query_first("SELECT articles_articleid FROM " . TABLE_PREFIX . "articles_article WHERE articles_articleid > $artid AND categoryid = $categoryid ORDER BY articles_articleid ASC LIMIT 1"))
{
$nextone = $nextone['articles_articleid'];
$nextarticle = 1;
}

if($previousone = $DB_site->query_first("SELECT articles_articleid FROM " . TABLE_PREFIX . "articles_article WHERE articles_articleid < $artid AND categoryid = $categoryid ORDER BY articles_articleid DESC LIMIT 1"))
{
$previousone = $previousone['articles_articleid'];
$prearticle = 1;
}


Decided to put in

AND categoryid = $categoryid

to limit to previous or next articles in the same category.

cinq
01-06-2005, 02:08 AM
I'm soooo looking forward to this!

I have this feature list to suggest;

1) List of article contributers (and auto link to their profile on the forum, if it exists)
2) List of "sources" of information borrowed from someonewhere else for purposes of the article
3) A ModCP panel to admin articles
4) An "edit log" shown on the side of the article front end; edits to the article can be optionaly given a reason for editing by the user, maybe with some predefined reasons such as "Language Error"

1) Yes, will be implemented. Currently, this is set up such that there is an author field, and there is a Posted by field ( as typically they can be 2 different persons or the author may not be a forum member ).

2) Already implemented, with a references/sources delimiting option in Admincp options to seperate each reference/source. Will only show at base of article if there are any. :)

3) I will stick to admincp first, but eventually may consider modcp as well.

4) Already implemented, also shows the date of the amendment. Amendment notes only appear in the backend when editting an article, no point having it when adding one. Also date of amendment is provided by time(), no need for user input. :)

oly51
01-06-2005, 09:50 AM
This is turning into exactly what I have been looking for. :classic:

Will it be possible to place an image thumbnail in the article next to its related text? Click on it for full view.

j_86
01-06-2005, 02:04 PM
This is incredible c1nq good job :)

cinq
01-07-2005, 03:31 AM
This is turning into exactly what I have been looking for. :classic:

Will it be possible to place an image thumbnail in the article next to its related text? Click on it for full view.

I am not totally understanding this.
Currently there is an article preview icon/image, with a link to the article proper.

cinq
01-07-2005, 09:48 AM
Here's another to ponder on .

Problem Number 3


# Categories and subcategories column
$parentcatquery = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "articles_category WHERE parentcategory=0 ORDER BY categoryorder");
if ($DB_site->num_rows($parentcatquery)>0)
{
while($parentcatrow=$DB_site->fetch_array($parentcatquery))
{
$parentid = $parentcatrow["articles_categoryid"];
$catname = $parentcatrow["categoryname"];
$parentcat = $parentcatrow["parentcategory"];

eval('$catlistbit .= "' . fetch_template('vbArticles_categorybit') . '";');
eval('$catlistbit .= "' . fetch_template('vbArticles_categorybit_pre') . '";');

$subcatquery = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "articles_category WHERE parentcategory = $parentid ORDER BY categoryorder");
if ($DB_site->num_rows($subcatquery)>0)
{
while($subcatrow=$DB_site->fetch_array($subcatquery))
{
$subcatid=$subcatrow["articles_categoryid"];
$subcatname=$subcatrow["categoryname"];
eval('$catlistbit .= "' . fetch_template('vbArticles_childcatbit') . '";');
}
}
eval('$catlistbit .= "' . fetch_template('vbArticles_categorybit_post') . '";');
}
}


I am trying to get the categories and then the subcategories of the parent category.
Is there anyway I can change things around to optimize what I am trying to do ?

As it is, this is probably the code portion contributing to the massive amount of queries ( testing : 32 queries at this time, with 4 parent cats, each with 5,4,1,6 subcats respectively )

oly51
01-07-2005, 09:56 AM
I am not totally understanding this.
Currently there is an article preview icon/image, with a link to the article proper.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.

nathanaus
01-07-2005, 10:10 AM
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?

rake
01-07-2005, 10:17 AM
// 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 :


$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.
* cinq worships rake ;)

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

cinq
01-08-2005, 03:39 AM
p.s. At this point in time, I am about 90% done, left with a comment validation system, article search feature for frontend, install script, and perhaps some small icon creation.

It would help speed things up if i could have some person(s) volunteer to do the nifty graphics, and install script, as well as volunteer to be beta testers as it will be released soon for beta testing. :)

------------------------------------
edit: article search done. :D

Guy G
01-08-2005, 07:47 AM
would be extremely great if there will be an importer from the v3 article hack...

cinq
01-08-2005, 07:54 AM
Well Zorobz, I have not used that hack myself and so don't know what it has done to store the articles and such.

Could be done as an add-on though, to give some the option of switching if they so desire. If someone wishes to volunteer to write an importer of sorts, drop me a PM too and I will provide the tables structure for my hack ;)

p.s. almost done with the comment validation system now too.
Eyes are tired ... must .... must carry on .... :D

j_86
01-08-2005, 12:36 PM
Cinq; is it possible to attatch standard files to articles? If so, where do they appear?

cinq
01-08-2005, 01:50 PM
Nope, not by default.

j_86
01-08-2005, 02:05 PM
Ah ok - can I make it a suggestion, then?

I can imagine a *lot* of tutorial based things will be wanting to attatch files other than images.

cinq
01-08-2005, 03:02 PM
pheww...comment validation done.
Time to get some rest before embarking on installation script ....

more updates tomorrow...i hope...;)

cinq
01-08-2005, 03:02 PM
Ah ok - can I make it a suggestion, then?

I can imagine a *lot* of tutorial based things will be wanting to attatch files other than images.

Yes, it will be included as a future feature.

cinq
01-09-2005, 05:45 AM
Tried integrating SPAW again, and again to no avail.
Seems to work when I upload it to my server ( just spaw demo ), but I cannot get it to work in my hack on localhost... bummer.

Does any one here use SPAW ?

Should I just not include any WYSIWYG editor ?
ie. no article images upload facility ... ( which most article require though I suspect )

SoloX
01-09-2005, 05:49 AM
noo!! keep working cinq ... i no u can do it... spaw or some other editor with upload capability .. is a must ...

but spaw is the coolest!

where does it break? I may be able to help u

cinq
01-09-2005, 06:04 AM
For my own use, I already purchased another WSYIWYG editor which integrates real easy and allows for image uploads and even sorting by folders etc.

I have an idea of how it can be done with Spaw as well ( making use of its dynamic img lib feature ).

Currently, when you add an article, the article 'pre-add' handler lets you input the article title first. It then checks the db for the last id entry and increases this count by one to create a folder in your set article img directory. This folder is the placeholder for this particular article's image(s).

This path ( the folder ) can be passed into the dynamic img lib array of Spaw, so that it looks into this folder for either img uploads or inserting of images into the article content.

All this sounds well and good, but at this point in time, I CANT EVEN GET THE EDITOR TO SHOW properly and it is really fustrating.

It gives me all sorts of warnings about not being able to include the neccessary config/control files in the spaw package.

And if I change a lot of the variables in the spaw config files, and do get rid of the warning erros ( hardcoded paths just to test mind you ...for e.g. C:/program files/wamp/www/spaw/config.blah blah ), the warning messages go away, the textarea box shows, but with no WYSIWYG editor interface, just the empty white textarea.....

arghh.

any ideas Solox ?

SoloX
01-09-2005, 06:12 AM
I was having similar path issues .. i manually entered these two variables to fix the path problems (in spaw_control.config.php) ..

$_SERVER['DOCUMENT_ROOT'] = '/home/html';
$HTTP_SERVER_VARS["DOCUMENT_ROOT"] = '/home/html';

spaw will not load properly if it cannot determine some of the paths .. try this and see if it helps ..

cinq
01-09-2005, 06:24 AM
Ok, I placed the spaw directory into the admincp dir.

I amended the spaw_control.config.php accordingly and this is what it is at the moment ( just the first few lines .. ):


// directory where spaw files are located
$spaw_dir = '/spaw/';

// base url for images
$spaw_base_url = 'http://localhost/image/articles';

if (!ereg('/$', 'c:/program files/wamp/www/forum/admincp'))
$spaw_root = 'c:/program files/wamp/www/forum/admincp'.$spaw_dir;
else
$spaw_root = 'c:/program files/wamp/www/forum/admincp'.substr($spaw_dir,1,strlen($spaw_dir)-1);


In my file, I added an include which looks like this :


include_once ('c:/program files/wamp/www/forum/admincp/spaw/spaw_control.class.php');


and call the instance using :


$sw = new SPAW_Wysiwyg('spaw1',stripslashes($HTTP_POST_VARS['spaw1']));
$sw->show();


Erros are gone now, but textarea no WYSIWYG controls.

Any ideas ?

p.s. thanks for the paths thingy :)

SoloX
01-09-2005, 06:42 AM
I notice u say spaw dir is /spaw/
its not under the root dir if i am reading your config files properly.
Put your entire spaw dir in root and change the include line.
OR
change the spaw dir accoring to the proper relative url

SoloX
01-09-2005, 06:51 AM
I am still not convinced spaw is finding all material it needs ..

can u put spaw in root dir and try this block in the config?

// directory where spaw files are located
$spaw_dir = '/spaw/';

// base url for images
$spaw_base_url = 'http://localhost/';

if (!ereg('/$', $HTTP_SERVER_VARS['DOCUMENT_ROOT']))
$spaw_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'].$spaw_dir;
else
$spaw_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'].substr($spaw_dir,1,strlen($spaw_dir)-1);

cinq
01-09-2005, 06:53 AM
yep, it is in my admincp dir :

ie. forum/admincp/spaw/

I will try your suggestion now.

cinq
01-09-2005, 07:06 AM
I notice u say spaw dir is /spaw/
its not under the root dir if i am reading your config files properly.
Put your entire spaw dir in root and change the include line.
OR
change the spaw dir accoring to the proper relative url



But I cannot change
$spaw_dir = '/spaw/';
to $spaw_dir = 'c:/program files/wamp/www/forum/admincp/spaw/';

based on the code here :
https://vborg.vbsupport.ru/showpost.php?p=592319&postcount=53

Since :

$spaw_root = 'c:/program files/wamp/www/forum/admincp'.$spaw_dir;

Changing it would make $spaw_root

'c:/program files/wamp/www/forum/admincp'.'c:/program files/wamp/www/forum/admincp/spaw/'

SoloX
01-09-2005, 07:10 AM
ohh .. leme PM u

cinq
01-09-2005, 09:00 AM
Close to 2 hrs of debugging SPAW with SoloX later, it still doesn't work .... darn it :(
Thanks for the help though SoloX, appreciate it greatly ! :D

cinq
01-09-2005, 12:44 PM
I give up with SPAW.

FCK next

cinq
01-10-2005, 01:07 PM
Just an update, optimized several queries with some help here (https://vborg.vbsupport.ru/showthread.php?t=74049)

Working on a report comment, edit comment, delete comment feature now.
Once done, will download FCK and give it a go.

I think I will then wrap things up with an installation script ( 40+ templates, many settings and phrases to create, plus 4 db tables creation ) , if FCK goes smoothly .... unlike spaw ...

Torqued
01-10-2005, 01:25 PM
woo hoo! can't wait to see this hack! :)

sabret00the
01-10-2005, 03:43 PM
Problem 2 solved ! ( thanks Rake ! )

Code used :

# previous and next article links
if($nextone = $DB_site->query_first("SELECT articles_articleid FROM " . TABLE_PREFIX . "articles_article WHERE articles_articleid > $artid AND categoryid = $categoryid ORDER BY articles_articleid ASC LIMIT 1"))
{
$nextone = $nextone['articles_articleid'];
$nextarticle = 1;
}

if($previousone = $DB_site->query_first("SELECT articles_articleid FROM " . TABLE_PREFIX . "articles_article WHERE articles_articleid < $artid AND categoryid = $categoryid ORDER BY articles_articleid DESC LIMIT 1"))
{
$previousone = $previousone['articles_articleid'];
$prearticle = 1;
}


Decided to put in

AND categoryid = $categoryid

to limit to previous or next articles in the same category.
you can do that in one query.

sabret00the
01-10-2005, 03:48 PM
1- pagination is a 3 lines code... already have something inside vB for that.
wow, it is, i haven't ever rewritten the code i was giving along time ago for sorting pagenav but the code i have is 30 lines long :shock:

please share the knowledge :o

cinq
01-11-2005, 12:08 AM
you can do that in one query.

Would be nice if you could share how to ?

cinq
01-11-2005, 07:09 AM
report comment, edit and delete comment done.
FCK's basic WSYIWYG integration works too, now working on the image upload handling in FCK. :D

sabret00the
01-11-2005, 08:01 AM
something like this

if ($nextone)
{ // set the variables
$nextone = $nextone['articles_articleid'];
$nextarticle = 1;
$articlenav_direction = ">";
$articlenav_order = "ORDER BY articles_articleid ASC";
}
else if ($previousone)
{
$previousone = $previousone['articles_articleid'];
$prearticle = 1;
$articlenav_direction = "<";
$articlenav_order = "ORDER BY articles_articleid DECS";
}

$articlenav = $DB_site->query_first("SELECT articles_articleid FROM " . TABLE_PREFIX . "articles_article WHERE articles_articleid $articlenav_direction $artid AND categoryid = $categoryid $articlenav_order LIMIT 1");

far from impressive really, both acheive the same thing as well, theris really no reason to switch since it don't perform the query unless asked to.

cinq
01-11-2005, 08:10 AM
I don't think your code does what I need it to do.
I need to query 2 times first to know if there are next or previous articles available.

In your code, if($nextone) or if($previousone) has no value initially...

cinq
01-11-2005, 09:43 AM
Hmm FCK's default resource browser is really confusing. I have stripped away code to simplify it but not exactly giving the full functionality I would hope for.

ie. when adding an article, a folder for that article for its images is automagically created and when browsing should be only able to see this created folder.
However it now sees all folders. There is no way to pass the folder path to FCK to tell it to dynamically only show that particular folder.

It just means that you will have to manually search for the folder ( i will provide an folder number for you to search for ), click on it, to show all the images, or upload images there as well.

If this sounds about good, I consider this hack done and I will move on to the installation script. Please let me know.

sabret00the
01-11-2005, 11:28 AM
I don't think your code does what I need it to do.
I need to query 2 times first to know if there are next or previous articles available.

In your code, if($nextone) or if($previousone) has no value initially...
the determination of the preview or next article before hand is impossible via my way you're right i apologise, however the $next and $preview comes from the url

i.e. <a href="http://localhost/forums/article.php?a=104845&nextone">next one</a> the code would work but not for what you need it for without getting creative in the most awesome ways imaginable :lol: joking.

cinq
01-11-2005, 02:14 PM
Hack has been released here (https://vborg.vbsupport.ru/showthread.php?t=74189)

Thanks for all the help rendered everyone :D

sabret00the
01-15-2005, 07:55 PM
wow, it is, i haven't ever rewritten the code i was giving along time ago for sorting pagenav but the code i have is 30 lines long :shock:

please share the knowledge :o
did the 3 line version of this never surface in this thread?

cinq
01-16-2005, 12:44 PM
Unfortunately nope.
I would be interested to know too.

rake
01-16-2005, 01:49 PM
Unfortunately nope.
I would be interested to know too.

This is the proper way to do pagination. It's from one of my scripts, and the original code is taken right out of vbulletin. All you need to edit are the two queries, the template that is called, and the fields you want to sort by.


// globalize variables
globalize($_REQUEST, array(
'pagenumber' => INT, // pagenumber
'perpage' => INT, // results per page
'sortfield' => STR, // field by which to sort results
'sortorder' => STR, // order in which to sort
));

if ($sortfield == '') {
$sortfield = 'name';
}

if ($sortorder == '') {
$sortorder = 'asc';
}



switch ($sortfield)
{
case 'name':
$sqlsort = 'name';
break;
case 'id':
$sqlsort = 'id';
break;
default:
$sqlsort = 'name';
$sortfield = 'name';
}


if ($sortorder != 'asc')
{
$sortorder = 'desc';
$oppositesort = 'asc';
}
else
{
// $sortorder = 'ASC';
$oppositesort = 'desc';
}


$sorturl = "$_SERVER[PHP_SELF]?$session[sessionurl]";


eval('$sortarrow[' . $sortfield . '] = "' . fetch_template('forumdisplay_sortarrow') . '";');



$dscount = $DB_site->query_first("
SELECT COUNT(*) AS count FROM site_garment
");
$dscount = $dscount['count'];

// set defaults
sanitize_pageresults($dscount, $pagenumber, $perpage, 100, 20);

$limitlower = ($pagenumber - 1) * $perpage+1;
$limitupper = ($pagenumber) * $perpage;
$counter = 0;

if ($limitupper > $dscount)
{
$limitupper = $dscount;
if ($limitlower > $dscount)
{
$limitlower = $dscount-$perpage;
}
}
if ($limitlower <= 0)
{
$limitlower = 1;
}


$spheres = $DB_site->query("SELECT * FROM site_garment ORDER BY $sqlsort $sortorder LIMIT ". ($limitlower-1) . ", $perpage");

$counter = 0;
$resultbits = '';
while ($grid = $DB_site->fetch_array($spheres) AND $counter++ < $perpage)
{

$grid[bonuses] = nl2br($grid[bonuses]);
eval('$dresspheres .= "' . fetch_template('site_ffx2_dsp_grid') . '";');



} // end while
$pagenav = construct_page_nav($dscount, "$_SERVER[PHP_SELF]?$session[sessionurl]", "&amp;pp=$perpage&order=$sortorder&amp;sort=$sortfield");

cinq
01-17-2005, 11:52 AM
Thanks again Alex, appreciate it :)
I will try your code when time permits.