New entries on top

Phoca Guestbook - creating guestbooks in Joomla! CMS
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47898
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: New entries on top

Post by Jan »

Hmm, really hard to say what can be wrong there :-(

Jan
If you find Phoca extensions useful, please support the project

Tags:
rosede
Phoca Enthusiast
Phoca Enthusiast
Posts: 73
Joined: 26 Mar 2011, 20:54

Re: New entries on top

Post by rosede »

Jan wrote: 19 Feb 2017, 19:27 Hmm, really hard to say what can be wrong there :-(

Jan
That's not very encouraging. What can I do?

Daryl
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47898
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: New entries on top

Post by Jan »

Hi, the problem is, there are many different parts (like server or database settings) which can somehow influence this, so it is really hard to say what can be wrong there. I tested this on 3 different servers without any such problem. The guide was based on user's experiences (in was made over time by different users, so there were experiences on different server by different users - tested and working after all the sql queries). So really hard to say if there is something specific on server or if there was something specific when migrating, or :idea: really hard to say.

This SQL should solve problems with ordering:

Code: Select all

    CREATE TABLE migrate AS
    SELECT id, 
     @rowid:=@rowid+2 AS rowid,
     @rowid - 1 AS lftnew,
     @rowid AS rgtnew FROM jos_phocaguestbook_items,
     (SELECT @rowid:=0) AS init
    ORDER BY id;
     
    UPDATE jos_phocaguestbook_items SET lft=(SELECT lftnew FROM migrate WHERE migrate.id = jos_phocaguestbook_items.id);
    UPDATE jos_phocaguestbook_items SET rgt=(SELECT rgtnew FROM migrate WHERE migrate.id = jos_phocaguestbook_items.id);
What are the values in menu link to guestbook:

- Order by
- Order direction
- Order direction
for comments


When changing them, does anything change on the site?
If you find Phoca extensions useful, please support the project
rosede
Phoca Enthusiast
Phoca Enthusiast
Posts: 73
Joined: 26 Mar 2011, 20:54

Re: New entries on top

Post by rosede »

Thank you Jan. I'll give this a try over the next couple of days and report back.

BTW, changing the ordering and sorting within the control panel does not change the postings on the website.

Thank you

Daryl
rosede
Phoca Enthusiast
Phoca Enthusiast
Posts: 73
Joined: 26 Mar 2011, 20:54

Re: New entries on top

Post by rosede »

Jan wrote: 23 Feb 2017, 02:09 Hi, the problem is, there are many different parts (like server or database settings) which can somehow influence this, so it is really hard to say what can be wrong there. I tested this on 3 different servers without any such problem. The guide was based on user's experiences (in was made over time by different users, so there were experiences on different server by different users - tested and working after all the sql queries). So really hard to say if there is something specific on server or if there was something specific when migrating, or :idea: really hard to say.

This SQL should solve problems with ordering:

Code: Select all

    CREATE TABLE migrate AS
    SELECT id, 
     @rowid:=@rowid+2 AS rowid,
     @rowid - 1 AS lftnew,
     @rowid AS rgtnew FROM jos_phocaguestbook_items,
     (SELECT @rowid:=0) AS init
    ORDER BY id;
     
    UPDATE jos_phocaguestbook_items SET lft=(SELECT lftnew FROM migrate WHERE migrate.id = jos_phocaguestbook_items.id);
    UPDATE jos_phocaguestbook_items SET rgt=(SELECT rgtnew FROM migrate WHERE migrate.id = jos_phocaguestbook_items.id);
What are the values in menu link to guestbook:

- Order by
- Order direction
- Order direction
for comments


When changing them, does anything change on the site?
Hello Jan,

I tried your sql code, but unfortunately it has errors:

Prior to running the sql I got this errors:

* An expression was expected (near()
* Unexpected token (near()
* This type of clause was previously parsed. (near SELECT)
* Unexpected token (near()
* Unrecognized keyword (near AS)
* Unexpected token. (near init)

The best taht I can tell, there is something wrong with this line:

(SELECT @rowid:=0) AS init

I don't know sql, so I can't tell if there is anything wrong or not.

Thanks

Daryl
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47898
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: New entries on top

Post by Jan »

Hi, maybe this is the reason why it does not order right as this SQL needs to run successfully to make the ordering right.

When you run it, do you get any specific SQL error (complete error)?
If you find Phoca extensions useful, please support the project
rosede
Phoca Enthusiast
Phoca Enthusiast
Posts: 73
Joined: 26 Mar 2011, 20:54

Re: New entries on top

Post by rosede »

Jan wrote: 27 Feb 2017, 16:38 Hi, maybe this is the reason why it does not order right as this SQL needs to run successfully to make the ordering right.

When you run it, do you get any specific SQL error (complete error)?
Hello Jan,

I figured out what I did wrong on the SQL statement. Totally my fault. I failed to change the table prefix to my table prefix.

I ran the query, but that did not resolve the issue. Sure, it fixed the current out-of-order postings, but when I submitted a new test post, it again went to the end of the guestbook. The lft value is 2 and the rgt value is 3.

Any additional thoughts?

Thank you.

Daryl
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47898
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: New entries on top

Post by Jan »

Hi, this should be Ok, the posts should go to the last position in database, but the ordering in menu link to guestbook is just set to display from newest to oldest :idea:

Jan
If you find Phoca extensions useful, please support the project
rosede
Phoca Enthusiast
Phoca Enthusiast
Posts: 73
Joined: 26 Mar 2011, 20:54

Re: New entries on top

Post by rosede »

Jan wrote: 02 Mar 2017, 17:32 Hi, this should be Ok, the posts should go to the last position in database, but the ordering in menu link to guestbook is just set to display from newest to oldest :idea:

Jan
Jan,

I had to read your reply a few times to understand what you meant. I finally understood that I needed to look in the "Options" for the guestbook menu. I see a "Order by" and changed it to Date. That resolved this issue. I did not know that I needed to look there. Why wouldn't that be in the normal options of the guestbook?

Thank you for your help.

Daryl
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47898
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: New entries on top

Post by Jan »

Hi,

OK.

Because you can have e.g. two guestbooks and two menu links and each can have own specific settings. This override of component's options by menu link is standard Joomla! feature which adds more options when creating website with Joomla!

Jan
If you find Phoca extensions useful, please support the project
Post Reply