103 Posts
Alain L
6 years ago
Topic

Hello,

I created a list of messages written by various users. I wish integrated the profile of the author (avatar and name) into every line of the list. I tried with various methods but without success. 
I'm waiting for advice. Many thanks

PS: Do we have to speak french, english or german here?

Get a VIP membership
572 Posts
_jrmo
6 years ago
10
Level 1

Hi Alain

On the public forums it is preferred that you speak English, because a greater number of the team (and the rest of the community) all speak English. On the VIP forums, French is welcome.

You must follow these steps very precisely. It also assumes you are using the user_avatar field that SEBLOD creates on the Default User Content Type.

  1. Open the Content Type of the Content you are listing (it is important that you do this in the content type so it is locked to this content type)
  2. Create a new field that is a "select dynamic"
  3. Change the Query to "free"
  4. Enter the following code
    SELECT b.avatar AS text, a.id AS value
    FROM #__users AS a
    LEFT JOIN #__cck_store_form_users AS b ON b.id = a.id
  5. Make sure the storage is Standard > Article > created_by
  6. Save your field, do not add it to your content type
  7. Open your Search and List Type and go to your Item view
  8. Add your field
  9. Apply the "image" typography

That should do the trick. Thanks for the question, it's a good one :)

_jrmo

103 Posts
Alain L
6 years ago
9
Level 2

Thank you very much. That works ... almost.

On step 9 if I apply 'none' as typography  the path of the image is correct ( pe:  images/users/banane.jpeg) BUT if I apply 'image'  the image doesn't display because the source of the image is the user id;  for example: <<a id="930" rel="930"></a><a id="930" rel="930"></a>

572 Posts
_jrmo
6 years ago
8
Level 3

Hi Alain, 

I'm glad that's working for you. Can you please check something for me?

If you add the HTML Typo on the field instead, and add 

<img src="/$cck->getValue('name_of_field');" />

Does it render the image properly? after you replace the name_of_field with your actual field name of course?

If you can confirm this, I will make this a "How-to" on the Tutorials resources page, as I think it will be useful for others.

_jrmo

103 Posts
Alain L
6 years ago
7
Level 4

It was a good idea but it doesn't work: same problem as type= 'image'.

this code in HTML typo: <img src="/$cck->getValue('an_avatar_createur');" /> <span> The path of the image is: $cck->getValue('an_avatar_createur') </span> return :  [no image] The path of the image is: 931

I think there's a problem with the 'getValue' method and the dynamic fields.

572 Posts
_jrmo
6 years ago
6
Level 5

What if you click the "3" and set the Markup to "none", type "clear" as the label and then use renderField instead of getValue?

103 Posts
Alain L
6 years ago
2
Level 6

No sorry it displays : "$cck->renderField('an_avatar_createur')"

572 Posts
_jrmo
6 years ago
1
Level 7

OK, thanks for trying! :) - you'll need to do a position override then, and use the getValue method in there.

572 Posts
_jrmo
6 years ago
0
Level 8

No! wait, try getText in the HTML typo. That should work!

103 Posts
Alain L
6 years ago
2
Level 6

Yes! 

The final solution is this one:

  1. Open the Content Type of the Content you are listing (it is important that you do this in the content type so it is locked to this content type)
  2. Create a new field that is a "select dynamic"
  3. Change the Query to "free"
  4. Enter the following code
    SELECT b.avatar AS text, a.id AS value
    FROM #__users AS a
    LEFT JOIN #__cck_store_form_users AS b ON b.id = a.id
  5. Make sure the storage is Standard > Article > created_by
  6. Save your field, do not add it to your content type
  7. Open your Search and List Type and go to your Item view
  8. Add your field   (example: name of the field : my_field )
  9. Apply the "HTML" typography  and write the HTML code

<img src= "$cck->getText('my_field')">

Thank you for your help

572 Posts
_jrmo
6 years ago
1
Level 7

Great :)

And just to explain, the reason we need to use getText is because in our query, we retrieved the avatar from the database as text with this line:

b.avatar AS text

So we must use getText instead of getValue.

103 Posts
Alain L
6 years ago
0
Level 8

By now I'm trying the same method with an other request: 

SELECT title FROM #__content where id_offre = 7 AND catid=18 

This request works fine on phpadmin and return 1 line but the field is empty.   Have you an idea?

233 Posts
pepperstreet
6 years ago
1
Level 1

Maybe I am lost in translation... but isn't it a feature and purpose of the "**Author**" field:
http://www.seblod.com/products/10868

103 Posts
Alain L
6 years ago
0
Level 2

Thank you Pepperstreet. I will try this plugin 'Author'.

for info, its description is: "Display the "Intro" view on the related content type based on the author of the content."

101 Posts
webchun
3 years ago
0
Level 1

Hello guys, sorry for bumping old thread. I'm coming from this tutorial and followed the instructions step by step. However I got error message :

1146 Table 'mytable.#__cck_store_form_users' Doesn't Exist

Not sure whether indeed the instruction is already outdated or I did something wrong, but changing the query to :
SELECT b.avatar AS text, a.id AS value FROM #__users AS a LEFT JOIN #__cck_store_item_users AS b ON b.id = a.id

solved my problem.

131 Posts
layonill
2 years ago
1
Level 1

in my case it appears broken the image, what about that?

41 Posts
KKAAZZOO
1 month ago
0
Level 2

I confirm the problem, displays a broken image.

Get a VIP membership