collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 396
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

If you're interested in helping other members with support requests, consider joining the Community Support Helpers group.

Author Topic: Grab avatar in query (custom block)  (Read 3971 times)

0 Members and 1 Guest are viewing this topic.

Offline Tarista

  • Semi Newbie
  • *
  • Posts: 37
  • SMF Version: 2.0.10
  • SP Version: 2.3.5
Grab avatar in query (custom block)
« on: June 10, 2015, 05:22:49 PM »
Hi,

I apologize, I wrote a long topic about how to modify a code and then ended up figuring out how to do it myself about half an hour later.

I know I could have answered my own question and left the content but it was not a complete block modification anyway so it wouldn't have worked out of the box for others :) I thought that it was better not taking up the recent posts.

Sorry about the unnecessary topic :)

Thanks!


Adding in what I removed since it could be useful according to replies :)

Here is the original topic:
Hope this is the right board for this :)

I'm trying to figure out how to add some information from the members-part of the database to a query. At the moment I'm trying to grab the avatar. All this is then going in a php block with even more codes but I thought I should perhaps not flood the topic with code and think this (below) is the part needed.

If I could just get help to figure out how to add it from the members table to the query I'm hopeful of trying to figuring out how to build it into the array myself. I wouldn't want to waste anyone's time.

I see that the code I have already (code found and edited years ago) joins the members table so now I'm just trying to figure out how to grab the information. Is it as simple as adding a row with mems.avatar and meml.avatar? (seems almost too simple?)

Code: [Select]
if ($do_query == 1)
{
$request = $smcFunc['db_query']("", "
SELECT
      ms.subject AS firstSubject, ms.poster_time AS firstPosterTime, ms.id_topic, t.id_last_msg, t.id_board, b.name AS bname,
      t.num_replies, t.num_views, ms.id_member AS ID_FIRST_MEMBER, ml.id_member AS ID_LAST_MEMBER,
      ml.poster_time AS lastPosterTime, IFNULL(mems.real_name, ms.poster_name) AS firstPosterName,
      IFNULL(meml.real_name, ml.poster_name) AS lastPosterName,
      mems.id_group as mems_group, meml.id_group as meml_group,
      ml.subject AS lastSubject, b.member_groups,
      t.is_sticky, t.locked, ml.modified_time AS lastModifiedTime,
      LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
      ml.smileys_enabled AS lastSmileys, ms.smileys_enabled AS firstSmileys, t.id_first_msg,"
      . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
      IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= ml.id_msg_modified AS isRead,
      IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . "
   FROM (".$db_prefix."messages AS ms, ".$db_prefix."messages AS ml, ".$db_prefix."topics AS t, ".$db_prefix."boards AS b)
      LEFT JOIN ".$db_prefix."members AS mems ON (mems.id_member = ms.id_member)
      LEFT JOIN ".$db_prefix."members AS meml ON (meml.id_member = ml.id_member)
      LEFT JOIN ".$db_prefix."log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = ".$user_info['id'].")
      LEFT JOIN ".$db_prefix."log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = ".$user_info['id'].")
   WHERE t.id_topic = ms.id_topic
      AND b.id_board = t.id_board" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.id_board != ".$modSettings['recycle_board'] : "") . "
      AND ms.id_msg = t.id_first_msg
      AND ml.id_msg = t.id_last_msg
      AND " . $user_info['query_see_board'] . "
   ORDER BY " . $order_clause . " " . $limit_clause,
 array());

Thank you for taking the time to read my question!
« Last Edit: June 10, 2015, 08:31:07 PM by Tarista »

Offline Burke Knight

  • Sr. Member
  • ****
  • Posts: 394
  • Gender: Male
  • I tell it how I see it. Don't like it? Hit Alt+F4
    • BurkeKnight Enterprises
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
Re: Remove this please :)
« Reply #1 on: June 10, 2015, 06:10:14 PM »
1. There was no reason to remove it.
2. You could have explained how you did it, in case someone else had same issue.

Offline Tarista

  • Semi Newbie
  • *
  • Posts: 37
  • SMF Version: 2.0.10
  • SP Version: 2.3.5
Grab avatar in query (custom block)
« Reply #2 on: June 10, 2015, 07:38:02 PM »
Alright :)

I just didn't want to bother people and was uncertain if this was even the right board since my custom block code might be considered unrelated to simpleportal even if I use it in a block with simpleportal. I apologize for not taking the time to explain it instead. I thought it wouldn't be of any use since I'm not really sure if I did it correctly anyway and the codes are still incomplete.

What I ended up doing was actually trying to change the query step by step. I studied how the "mems.id_group as mems_group, meml.id_group as meml_group" was built, compared it to other recent-blocks I found here on this site and then checked the database to find as I suspected that id_group is indeed in the members-table. I then copied that onto a new line and changed the structure/parts of the new line.

Code: (This is the new line) [Select]
mems.avatar as mems_avatar, meml.avatar as meml_avatar
Added that to the query and tried previewing it in my block. It worked as intended and after adding it to the building array I could then actually use it with ['first_post']['member']['avatar'] :) No guaranties it was the correct way to do it since I'm beginner coder still using the trial and error-method.

I was uncertain if this was actually of any help to people so that is why I originally removed it. Also not sure if it was the right board.

If it's of any use and this was actually the correct board it could be left here if you want it to. If not, it can safely be removed since my problem is solved :)
« Last Edit: June 10, 2015, 08:28:22 PM by Tarista »