Topic: Toptcs order by User

Hi,
long time ago but i have another problem...

I would like to insert an order-option of the topics in the forum. The users decide in his attitudes himself in which direction he would like to read. So, if anyone like to read the last topic first, he could change it....

I hope u understand me ... smile

Best regards
Michaela

Re: Toptcs order by User

Its important ...

please help me ....

Michaela

3 (edited by Connorhd 2005-01-19 16:04)

Re: Toptcs order by User

you could add order by by.. links at the bottom of it and then in viewforum use the get variable to decide what to order by

4 (edited by cherry1499 2005-01-20 15:07)

Re: Toptcs order by User

What do u mean?
I dont understand it ...

Well sure, but i dont know, how i realize it ...  sad

I know, that i need to change the Line in viewforum.php "order by ...". But i dont know, how i can insert the tag at the bottom of the forum, to change the direction of the topics ...

Greetings
Michaela

Re: Toptcs order by User

Theres a few things you need to do for this to work.
You need to add a feild in the users table in the database called 'forum_order'. This wioll either be ASC or DESC.

Then in viewforum.php, find this
$sql = 'SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];

Replace with

$sql = 'SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' '.$pun_user['forum_order'].' LIMIT '.$start_from.', '.$pun_user['disp_topics'];

I have no clue how this will work, and will only work if you turn off the 'dot' in the admin options. Please backup your file before trying this

Indocron
$theQuestion = (2*b) || !(2*b);

6 (edited by Smartys 2005-01-21 00:00)

Re: Toptcs order by User

You need to add it to profile.php as well (that is to say, you need to add a way for the user to set their choice in profile.php) smile
Alternatively, you could just choose to add code so the user can add "order=asc" or "order=desc" to their URLs to sort the forum like that.

7 (edited by Gary13579 2005-01-21 00:05)

Re: Toptcs order by User

Yes, but then they have to modify the URL everytime they click on the forum tongue

Indocron
$theQuestion = (2*b) || !(2*b);

Re: Toptcs order by User

True, but it doesn't require editing the database!

Re: Toptcs order by User

But editing one line in the database is better then editing the URL everytime you want to view a forum wink

Indocron
$theQuestion = (2*b) || !(2*b);

Re: Toptcs order by User

Plus adding stuff to profile.php so the the user can set their preference smile
It all depends if you want to make more work for yourself. tongue
Plus, why in the world would someone always want to see the oldest posts anyway? I think they just want a way to start looking at the oldest posts wink

11 (edited by cherry1499 2005-01-21 12:48)

Re: Toptcs order by User

Guys, u make me crazy ...  big_smile
So, i need to insert a field in my users table called forum_order .... Then replace the code above in the viewforum.php.
But what i need to do with the profile.php? I see, u know what i mean, but i dont understand anything. Sorry!

You need to add it to profile.php as well (that is to say, you need to add a way for the user to set their choice in profile.php) 
Alternatively, you could just choose to add code so the user can add "order=asc" or "order=desc" to their URLs to sort the forum like that.

How can i realize it ?

Greetings
Michaela

Re: Toptcs order by User

i don't really understand this, why would you ever want to read the last topic first?

Re: Toptcs order by User

That was what I thought tongue
If you were manually searching for something old perhaps?

Re: Toptcs order by User

Because some of my members would like to read the forum at the other direction ....
So, can u help me please?

Greetings
Michaela

15 (edited by cherry1499 2005-01-22 09:30)

Re: Toptcs order by User

Ok, i try all, but i think u dont understand ..  big_smile

I would like an option für users, that he can choose the direction of the topics ... not the forum!
So, if u open a topic, the first is the neweset message ...

I can change it in the viewtopic.php by

$result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.status, u.registered, u.admin_note, p.id, p.poster, p.poster_id, p.poster_ip, p.poster_email, p.message, p.smilies, p.posted, p.edited, p.edited_by FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id WHERE p.topic_id='.$id.' ORDER BY p.id DESC LIMIT '.$start_from.','.$disp_posts) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

but some usere would like to red the messages normal ....

Example: This are messages in a topic and how do u can read it ...
Normal - 1. a week ago - 2. yesterday - 3. today
with the (choose)mod - 1. today - 2. yesterday - 3. a week ago
Sorry, if i dont could explain it right ...

Greetings
Michaela

Re: Toptcs order by User

ahhh that makes alot more sense wink, do you want it to be set in the user profile or just a button added on each page to reverse the order?

Re: Toptcs order by User

yeeahhhhhh  smile

I think its better at the profile ....  The guest could only at the normal direction ... And the user only, if they change it in the profile ...

Michaela

Re: Toptcs order by User

Well, have anyone an idea?
Please, because i try sooo much, but nothing  works ....

Greetings
Michaela

Re: Toptcs order by User

ok, i think 4 days is enough to think about it ... big_smile
Please, i will be pleasure, if anyone have a solution for my problem ...

Michaela

20 (edited by cherry1499 2005-01-29 09:43)

Re: Toptcs order by User

Well, i write my steps ...

I create a field in my database in users names order_form ...

in my profil.php i have now this code

<input name="form[order_form]" type="checkbox" value="1" <?php if ($user['order_form'] == '1') echo ' checked' ?>>

So, if anyone would read the post reverse, he need to check it ...

In the viewtopi.php i try this

if $cur_user['richtung'] != 'order=asc')
    $result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.status, u.registered, u.admin_note, p.id, p.poster, p.poster_id, p.poster_ip, p.poster_email, p.message, p.smilies, p.posted, p.edited, p.edited_by FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id WHERE p.topic_id='.$id.' ORDER BY p.id DESC LIMIT '.$start_from.','.$disp_posts) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

else
    $result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.status, u.registered, u.admin_note, p.id, p.poster, p.poster_id, p.poster_ip, p.poster_email, p.message, p.smilies, p.posted, p.edited, p.edited_by FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id WHERE p.topic_id='.$id.' ORDER BY p.id LIMIT '.$start_from.','.$disp_posts) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

The Profil works with the Database, if i check it, i find the 1 in my database, but the little heel are not in the checkbox... 
But i become an error: "Parse error: parse error, unexpected T_VARIABLE, expecting '(' in .../viewtopic.php ..."

Well, thats newby trash, but i try it .... smile

Michaela

Re: Toptcs order by User

Ok guys, it works and perhaps somebody would use it too ...

1. insert a field names order_form in Table "users" (tinyint = 1).

2. profil.php

find:

if ($form['link_to_new_win'] != '1') $form['link_to_new_win'] = '0';

after it

if ($form['order_form'] != '1') $form['order_form'] = '0';

The replace this

$result = $db->query('SELECT username, email, title, realname, url, icq, msn, aim, yahoo, location, use_avatar, signature, disp_topics, disp_posts, email_setting, save_pass, notify_with_post, smilies, show_img, show_avatars, show_sig, link_to_new_win, timezone, style, num_posts, status, last_post, registered, admin_note FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());

with this

$result = $db->query('SELECT username, email, title, realname, url, icq, msn, aim, yahoo, location, use_avatar, signature, disp_topics, disp_posts, email_setting, save_pass, notify_with_post, smilies, show_img, show_avatars, order_form, show_sig, link_to_new_win, timezone, style, num_posts, status, last_post, registered, admin_note FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());

The find this

<?php echo $lang_prof_reg['Save user/pass info'] ?></div>
        <input type="checkbox" name="form[save_pass]" value="1"<?php if ($user['save_pass'] == '1') echo ' checked' ?>>
         <?php echo $lang_prof_reg['Save user/pass'] ?>

and replace it with this

<input name="form[order_form]" type="checkbox" value="1" <?php if ($user['order_form'] == '1') echo ' checked' ?>>
            I would read the newest postings first. 
          </p>
          </div>
        <div style="padding-left: 4px"><?php echo $lang_prof_reg['Save user/pass info'] ?></div>
        <input type="checkbox" name="form[save_pass]" value="1"<?php if ($user['save_pass'] == '1') echo ' checked' ?>>
         <?php echo $lang_prof_reg['Save user/pass'] ?>

3. viewtopic.php

find this

$result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.status, u.registered, u.admin_note, p.id, p.poster, p.poster_id, p.poster_ip, p.poster_email, p.message, p.smilies, p.posted, p.edited, p.edited_by FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id WHERE p.topic_id='.$id.' ORDER BY p.id LIMIT '.$start_from.','.$disp_posts) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

and replace with this

if ($cur_user['order_form'] == '1')
    $result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.status, u.registered, u.admin_note, p.id, p.poster, p.poster_id, p.poster_ip, p.poster_email, p.message, p.smilies, p.posted, p.edited, order_form, p.edited_by FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id WHERE p.topic_id='.$id.' ORDER BY p.id DESC LIMIT '.$start_from.','.$disp_posts) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
else
    $result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.status, u.registered, u.admin_note, p.id, p.poster, p.poster_id, p.poster_ip, p.poster_email, p.message, p.smilies, p.posted, p.edited, order_form, p.edited_by FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id WHERE p.topic_id='.$id.' ORDER BY p.id LIMIT '.$start_from.','.$disp_posts) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

Thanks too gary, who gives me the idea for this option ...  wink

Well, i wish u a nice weekend guys and thx for this awesome forum .... big_smile

Michaela