Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Article Manager v1.0


RobAnderson

Recommended Posts

Thanks for your feedback, found a solution to remove the prepended parent id and underscore and now it works for subtopics.

That might bereak the Header Tags SEO pseudo code option, which is one of the main advantages of this version of Article Maanger.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Hi Jack,

Re: ArticlesManager_1.57_5

 

When onsite Users upload an article there is no author name nor author info

associated with it, which poses a problem with the content display after clicking

the Article Box options, namely no author name for the article and even after adding

an author name in admin because the author_info table is not filled on the initial

upload, it affects the content display when clicking the author in author box because the

Heading says Articles by (blank)

anyway, here is a snippet that fills in the author and author_info tables when the user is logged in.

Requires adding customer_id field to TABLE_AUTHORS

 

in NEWFILES/article-submit.php

 

AFTER

if (! $error)

{

 

ADD

// 9-24-10 added to put Author/Customer name and generic Author info into db when User is logged in

// Requires adding customer_id field to TABLE_AUTHORS

 

if (tep_session_is_registered('customer_id')) {

$account_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");

$account = tep_db_fetch_array($account_query);

 

$author_name = $account['customers_firstname'] . ' ' . $account['customers_lastname'];

 

$author_query = tep_db_query("select authors_id, authors_name from " . TABLE_AUTHORS . " where customers_id = '" . (int)$customer_id . "'");

$author = tep_db_fetch_array($author_query);

 

if ($author['authors_id'] < 1) {

 

// no author_id found for this customer need to add

$authors_date_added = date('Y-m-d');

$sql_data_array = array('authors_name' => $author_name,

'date_added' => $authors_date_added,

'customers_id' => (int)$customer_id);

 

tep_db_perform(TABLE_AUTHORS, $sql_data_array);

$authors_id = tep_db_insert_id();

 

// add generic author description to authors_info table

 

$languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");

while ($languages = tep_db_fetch_array($languages_query)) {

$languages_array[] = array('id' => $languages['languages_id'],

'name' => $languages['name'],

'code' => $languages['code'],

'image' => $languages['image'],

'directory' => $languages['directory']);

}

 

$authors_description = $author_name . " is a valued member of our community.";

$authors_url = '';

 

$languages = $languages_array;

 

// used optimize array technique including ++$i instead of - for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

$max = sizeof($languages);

for ($i=0; $i<$max; ++$i) {

 

$language_id = $languages[$i]['id'];

 

$sql_data_array = array('authors_description' => $authors_description ,

'authors_url' => $authors_url);

 

$insert_sql_data = array('authors_id' => $authors_id,

'languages_id' => $language_id);

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_AUTHORS_INFO, $sql_data_array);

}

 

} else {

 

// found customer's authors_id

$authors_id = $author['authors_id'];

}

} // X if (tep_session_is_registered('customer_id')) {

// X 9-24-10 added to put Author/Customer name and generic Author info into db

 

(Hope you don't mind my posting this, just wanted to share)

jk

 

Hello Thank Jack for this great contrib, I have added the code from jfkafka because had no autors name. But it does not work fine :

I got this message :

1054 - Unknown column 'customers_id' in 'where clause'

 

select authors_id, authors_name from authors where customers_id = '2'

I have added the customer_id field - INT (11)in the authors table. SO I don't understand why I got this message.

Link to comment
Share on other sites

Like some posts above, just want to say that multi language does not work also here !

 

I have french as main language (admin and catalog).

In the admin I can see the 3 languages fields but only french is saved !

I have checked that the same for the topics, only the french version is saved.

I just can see my articles in french in the database (english and italian).

 

Any idea ?

Link to comment
Share on other sites

Hello Thank Jack for this great contrib, I have added the code from jfkafka because had no autors name. But it does not work fine :

I got this message :

1054 - Unknown column 'customers_id' in 'where clause'

 

select authors_id, authors_name from authors where customers_id = '2'

I have added the customer_id field - INT (11)in the authors table. SO I don't understand why I got this message.

Got that one, the field to be added is not customer_id but customers_id !

Now I can see the articles but the author name is still 0 in the table and doesn't appear besides the article name.

Link to comment
Share on other sites

Got that one, the field to be added is not customer_id but customers_id !

Now I can see the articles but the author name is still 0 in the table and doesn't appear besides the article name.

 

just tried it and it works fine for me

some initial thoughts/questions

1. author name is 0 - you don't mean customers_id, do you?

2. The logged in customer name is not (by some chance) 0, right?

 

jk

Link to comment
Share on other sites

That might bereak the Header Tags SEO pseudo code option, which is one of the main advantages of this version of Article Maanger.

 

Okay, plan b-

remove the code to strip off the preceding digit and underscore

go back to original code in catalog/includes/boxes/articles.php:

$tPath_new = 'tPath=' . $tree[$counter]['path'];

and modify the htaccess file:

 

FROM:

RewriteRule ^(.*)-t-([0-9]+).html$ articles.php?tPath=$2&%{QUERY_STRING}

 

TO:

RewriteRule ^(.*)-t-(.*).html$ articles.php?tPath=$2&%{QUERY_STRING}

 

this now works with the correct URL:

http://www.localdev.com/public_html/website-design-t-2_3.html

 

better?

jk

Link to comment
Share on other sites

Okay, plan b-

remove the code to strip off the preceding digit and underscore

go back to original code in catalog/includes/boxes/articles.php:

$tPath_new = 'tPath=' . $tree[$counter]['path'];

and modify the htaccess file:

 

better?

I'm sorry but I don't see the point. Was the code not working for you or did you just not like the appearance?

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

I'm sorry but I don't see the point. Was the code not working for you or did you just not like the appearance?

 

It was giving a 404 error- page not found - when clicking on a subtopic folder (ex t-2_3.html)

this only happened on a localhost running xxamp with php5.3, the hosted sites (<php5.3)

didn't have a problem with subtopics.

 

btw - the appearance is terrific

jk

Edited by jfkafka
Link to comment
Share on other sites

It was giving a 404 error- page not found - when clicking on a subtopic folder (ex t-2_3.html)

this only happened on a localhost running xxamp with php5.3, the hosted sites (<php5.3)

didn't have a problem with subtopics.

jk

Ahh, I understand now. Thanks for the explanation.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

RE: ArticlesManager 1.57_5

Question du jour

There's a field for authors_image in the author's table.

Is it supposed to be displayed somewhere?

 

Also, what do you think about adding a print button?

The authors image is part of the original contribution (different programmer) and was never used, at least that I know of.

 

The print option is probably a good idea. I don't use the contribution much so don't have much real-world experience with its usage but I could see where a visitor to the site might want to print the article.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

help needed..

 

The following code from admin/includes/functions/articles.php get stuck in an infinite loop until memory_limit is reached and an error message is displayed in the admin panel.

 

This is the function that is causing the infinite loop:

 

function tep_get_topic_tree($parent_id = '0', $spacing = '', $exclude = '', $topic_tree_array = '', $include_itself = false) {

global $languages_id;

 

if (!is_array($topic_tree_array)) $topic_tree_array = array();

if ( (sizeof($topic_tree_array) < 1) && ($exclude != '0') ) $topic_tree_array[] = array('id' => '0', 'text' => TEXT_TOP);

 

if ($include_itself) {

$topic_query = tep_db_query("select cd.topics_name from " . TABLE_TOPICS_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.topics_id = '" . (int)$parent_id . "'");

$topic = tep_db_fetch_array($topic_query);

$topic_tree_array[] = array('id' => $parent_id, 'text' => $topic['topics_name']);

}

 

$topics_query = tep_db_query("select c.topics_id, cd.topics_name, c.parent_id from " . TABLE_TOPICS . " c, " . TABLE_TOPICS_DESCRIPTION . " cd where c.topics_id = cd.topics_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.topics_name");

while ($topics = tep_db_fetch_array($topics_query)) {

if ($exclude != $topics['topics_id']) $topic_tree_array[] = array('id' => $topics['topics_id'], 'text' => $spacing . $topics['topics_name']);

$topic_tree_array = tep_get_topic_tree($topics['topics_id'], $spacing . '   ', $exclude, $topic_tree_array);

}

 

return $topic_tree_array;

}

 

 

Anyone who can help will be a life saver...

Link to comment
Share on other sites

just tried it and it works fine for me

some initial thoughts/questions

1. author name is 0 - you don't mean customers_id, do you?

2. The logged in customer name is not (by some chance) 0, right?

 

jk

 

Hello thank you for your answer.

The customer name is not 0, the customer_id is 2 but in the article table, the author-id field is filled with 0.

Link to comment
Share on other sites

Hello thank you for your answer.

The customer name is not 0, the customer_id is 2 but in the article table, the author-id field is filled with 0.

 

Well I've made a check in the table "article" this is really the place where something is missing. I don't see any code to add the authors_id value in the table "articles".

Link to comment
Share on other sites

Well I've made a check in the table "article" this is really the place where something is missing. I don't see any code to add the authors_id value in the table "articles".

 

Hi

 

in case it's still not working,

 

in catalog/article_submit.php

this puts the authors_id in articles table

 

$sql_data_array = array('articles_date_available' => $articles_date_available,

'articles_date_added' => $articles_date_available,

'articles_status' => 0,

'authors_id' => $authors_id);

 

tep_db_perform(TABLE_ARTICLES, $sql_data_array);

 

in fact here is my entire block of code so you can compare it to yours

just in case whatever:

 

=========Start here=============

 

if (! $error)

{

 

// 9-24-10 added to put Author/Customer name and generic Author info into db when User is logged in

// Requires adding customers_id field to TABLE_AUTHORS

if (tep_session_is_registered('customer_id')) {

$account_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");

$account = tep_db_fetch_array($account_query);

 

$author_name = $account['customers_firstname'] . ' ' . $account['customers_lastname'];

 

$author_query = tep_db_query("select authors_id, authors_name from " . TABLE_AUTHORS . " where customers_id = '" . (int)$customer_id . "'");

$author = tep_db_fetch_array($author_query);

 

if ($author['authors_id'] < 1) {

 

// no author_id found for this customer need to add

$authors_date_added = date('Y-m-d');

$sql_data_array = array('authors_name' => $author_name,

'date_added' => $authors_date_added,

'customers_id' => (int)$customer_id);

 

tep_db_perform(TABLE_AUTHORS, $sql_data_array);

$authors_id = tep_db_insert_id();

 

// add generic author description to authors_info table

 

$languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");

while ($languages = tep_db_fetch_array($languages_query)) {

$languages_array[] = array('id' => $languages['languages_id'],

'name' => $languages['name'],

'code' => $languages['code'],

'image' => $languages['image'],

'directory' => $languages['directory']);

}

 

$authors_description = $author_name . " is a valued member of our community.";

$authors_url = '';

 

$languages = $languages_array;

 

// used optimize array technique instead for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

$max = sizeof($languages);

for ($i=0; $i<$max; ++$i) {

 

$language_id = $languages[$i]['id'];

 

$sql_data_array = array('authors_description' => $authors_description ,

'authors_url' => $authors_url);

 

$insert_sql_data = array('authors_id' => $authors_id,

'languages_id' => $language_id);

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_AUTHORS_INFO, $sql_data_array);

}

 

 

} else {

// found customer authors_id

$authors_id = $author['authors_id'];

}

} // X if (tep_session_is_registered('customer_id')) {

// X 9-24-10 added to put Author/Customer name and generic Author info into db

 

$articles_date_available = date('Y-m-d');

$sql_data_array = array('articles_date_available' => $articles_date_available,

'articles_date_added' => $articles_date_available,

'articles_status' => 0,

'authors_id' => $authors_id);

 

tep_db_perform(TABLE_ARTICLES, $sql_data_array);

$articles_id = tep_db_insert_id();

 

=========End of Code=========

 

 

the next line of code should be(just a reference point):

tep_db_query("insert into " . TABLE_ARTICLES_TO_TOPICS . " (articles_id, topics_id) values ('" . (int)$articles_id . "', '" . (int)$topic . "')");

 

this should be all that's required to fill the author and articles table with the authors_id

 

jk

Link to comment
Share on other sites

Hi Jack,

 

Do you know how to put an infobox inside another infobox array?

 

for instance:

new infoButton($info_button_contents[$cur_row], $button_name);

generates an infobox button called "Remove".

 

Is it possible to add this infobox Remove button to an infobox array of articles?

 

This line simply adds the text not the button itself (obviously)

$info_box_contents[$cur_row][] = array('align' => 'center',

'params' => 'class="articleListing-data" valign="top"',

'text' => 'new infoButton($info_button_contents[$cur_row], 'Remove');');

 

Thanks for any help.

jk

Link to comment
Share on other sites

Hi Jack,

 

Do you know how to put an infobox inside another infobox array?

 

for instance:

new infoButton($info_button_contents[$cur_row], $button_name);

generates an infobox button called "Remove".

 

Is it possible to add this infobox Remove button to an infobox array of articles?

 

This line simply adds the text not the button itself (obviously)

$info_box_contents[$cur_row][] = array('align' => 'center',

'params' => 'class="articleListing-data" valign="top"',

'text' => 'new infoButton($info_button_contents[$cur_row], 'Remove');');

I'm sure it is possible, though the box class may need some editing. But the normal way of doing it is change the code for the main infobox before it is created. Just find the post inthe code above the infobox code where you want to make a change and make it there. Then the normal infobox code will handle everything else.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

I'm sure it is possible, though the box class may need some editing. But the normal way of doing it is change the code for the main infobox before it is created. Just find the post inthe code above the infobox code where you want to make a change and make it there. Then the normal infobox code will handle everything else.

 

I'm not sure what you mean by "find the post" (not that I remotely understand

what to do once I find it). Sorry to be so dense especially because you were

kind enough to answer. Is there example in existing code where this is done?

Thanks,

jk

Link to comment
Share on other sites

I'm not sure what you mean by "find the post" (not that I remotely understand

what to do once I find it). Sorry to be so dense especially because you were

kind enough to answer. Is there example in existing code where this is done?

I'm sorry, I meant to type part. Somewhere in the code above the infobox will be a <tr><td><.td></tr> piece of code. If you want to surround that with another table, then insert it there. If a table is to surround the entire contents, then insert the first part of the table as the first element of the content array and the closing part as the last element.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Hello Jack,

 

Thank's for your answer :

$sql_data_array = array('articles_date_available' => $articles_date_available,

'articles_date_added' => $articles_date_available,

'articles_status' => 0,

'authors_id' => $authors_id);

 

That fixes my issue :

'authors_id' => $authors_id); was written 'authors_id' => ''); (from the file I downloaded).

Every thing is working now except the multiple language option.

Have a good day

Link to comment
Share on other sites

Hi Jack,

 

Thanks for your response. When an infobox is created

how do you refer to it, like if you wanted to store the value in a variable

that when echoed would produce the infobox, is it even possible to do

without involved coding?

 

Thanks for your patience and guidance,

jk

Link to comment
Share on other sites

Hello Jack,

 

Thank's for your answer :

$sql_data_array = array('articles_date_available' => $articles_date_available,

'articles_date_added' => $articles_date_available,

'articles_status' => 0,

'authors_id' => $authors_id);

 

That fixes my issue :

'authors_id' => $authors_id); was written 'authors_id' => ''); (from the file I downloaded).

Every thing is working now except the multiple language option.

Have a good day

 

Hi,

 

I posted my admin/articles.php with the modifications to make the multiple languages update in the admin area.

 

See it at http://addons.oscommerce.com/info/1709 .

 

Jack, excuse me for posting it in your add-on as I know you do not appreciate playing around with your contributions (that we all love!) but as so many have this problem I hope this fix is OK for you.

 

thanks again for this awesome contribution.

 

Barbara

Link to comment
Share on other sites

Thanks for your response. When an infobox is created

how do you refer to it, like if you wanted to store the value in a variable

that when echoed would produce the infobox, is it even possible to do

without involved coding?

The array that is sent to the infobox code can contain any data and/or formatting, as long as it is valid. The infobox code then takes that and inserts it into a table and displays it. Thee's nothiing special about the infobox call. It is just a way to draw a table over and over without having to write the code each time. But the tables are fixed. If you want to change those, you either need to add a new class to the includes/classes/boxes.php file, insert code into the array, as explained previosuly, or just remove the infobox call and build your own table using the data in the content array.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Jack, excuse me for posting it in your add-on as I know you do not appreciate playing around with your contributions (that we all love!) but as so many have this problem I hope this fix is OK for you.

I appreciate the thought but there's no need to worry about how I feel about this. It isn't my contribution - I just added to it and anyone else is free to do the same.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...