Skip to Content Skip to Menu

CB Articles

  • sylvanr
  • sylvanr
  • OFFLINE
  • Posts: 32
  • Thanks: 1
  • Karma: 0
9 years 6 months ago #262324 by sylvanr
CB Articles was created by sylvanr
3 weeks and 4 days ago, I had asked about the order of articles/items displayed with CB Articles. The default is to order them by date created. I had asked about changing the "sort" or "order by" to categories. My understanding was that I needed to go to components/com_comprofiler/plugin/user/plug_cbarticles/models/joomla25.php and for Joomla articles or components/com_comprofiler/plugin/user/plug_cbarticles/models/k2.php for K2 items/articles. Then I would change this line of code: "\n ORDER BY a." . $_CB_database->NameQuote( 'created' ) . " DESC";

I assume 'created' refers to date created? So I would just change 'created' to 'category_title' if I want to sort by category title?

Since then, I realized that it would be even better to sort by the item (article) title since then the end user could number the articles in the specific order they want them to appear. So if that is the case, would I just change 'created' to 'name' ??

I suppose I could just try different things but editing php is a bit intimidating for me and always afraid I am going to totally mess things up. Before I do anything, I will make a backup but thought I would check again, just to make sure I am on the right path for changing the order of the K2 items displayed in CB Articles.

As always, thanks for your assistance.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
9 years 6 months ago #262399 by krileon
Replied by krileon on topic CB Articles
Check the database table for Joomla articles and/or K2 articles. You can order by any of them. For K2 the table is _k2_items. For Joomla the table is _content. For your specific case you'd order by title. A parameter to change the order by is planned for a later release so you eventually won't have to change it in PHP anymore.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • sylvanr
  • sylvanr
  • OFFLINE
  • Posts: 32
  • Thanks: 1
  • Karma: 0
9 years 6 months ago - 9 years 6 months ago #262515 by sylvanr
Replied by sylvanr on topic CB Articles
Well, I decided to go ahead and try changing the sort order in the php. I was still not sure what would work better for the sort, category id or name so I decided to try category id first.

I went to components/com_comprofiler/plugin/user/plug_cbarticles/models/k2.php and opened k2.php in text editor and found the line \n ORDER BY a." . $_CB_database->NameQuote( 'created' ) . " DESC"; and changed it to "\n ORDER BY a." . $_CB_database->NameQuote( 'catid' ) . " ASC";

I didn't change anything else. I got this error message:

Parse error: syntax error, unexpected T_NS_SEPARATOR in /home/nretrosp/public_html/components/com_comprofiler/plugin/user/plug_cbarticles/models/k2.php on line 110

In the text editor, I went to line 110 and this is what was highlighted:

Parse error: syntax error, unexpected T_NS_SEPARATOR in <span>/</span>home<span>/</span>nretrosp/public_html/components/com_comprofiler/plugin/user/plug_cbarticles/models/k2.php on line 110

Not sure what I am doing wrong??
Last edit: 9 years 6 months ago by sylvanr.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
9 years 6 months ago - 9 years 6 months ago #262550 by krileon
Replied by krileon on topic CB Articles
The ORDER BY is the part of the query that changes the ordering. You shouldn't get any PHP errors, because you're not supposed to touch the surrounding PHP. You strictly only need to change the 'catid' string to for example 'title'. So you'd have the following.

FROM:
Code:
"\n ORDER BY a." . $_CB_database->NameQuote( 'catid' ) . " ASC";
TO:
Code:
"\n ORDER BY a." . $_CB_database->NameQuote( 'title' ) . " ASC";


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 9 years 6 months ago by krileon.
The following user(s) said Thank You: nant

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum