By liliplanet on
Hi All!
I'm pretty new here and so excited to all the possibilities.
I've done an extensive search and cannot find the answer to this:
My site is a film news site and would like the certain profile fields on the user's article / story submission at the bottom of the article.
I've tried contemplate adding ie.
<?php if($user->profile_experience): ?>
<div class="fields"><?php print check_markup($user->profile_experience) ?></div>
<?php endif ?>but it does not show up on the article.
Please, how would I go about that .. any direction would be most appreciated.
All the best,
Lilian
Comments
can you edit your theme
can you edit your theme node.tpl.php file? If so then you could use the code above after doing a and insert it in the appropriate place after the page or story.
Your problem above may be that the $user field may not be available to the contemplate engine - try output placeholders to see if contemplate is working and then take it to the next step - you may have to load the user to get access to the profile_experience. Also by default if you have access to a $user - it may be the current logged in user and not the story's author.
still struggling to add profile field into story
Dear Panis,
Thank you so much for your reply. Panis, I've tried adding :
to the node.tpl.php, and still no joy there.
when I add $user = user_load($node->uid); I receive errors.
Another question .. if we do add the profile field into the node.tpl, surely it will then show on the teaser as well?
I found the following :
would that be of any help?
Look so forward to any reply.
Sincere regards,
Lilian
Call to user_load is incorrect
The call to user_load should look like
I also strongly recommend not using $user as a variable name unless you are using it to refer to the current user (in which case it needs to be declared global).
Thank you Nevets, This would
Thank you Nevets,
This would be fabulous .. if I knew where to put the code as quite confused here now.
Do I add it to node.tpl.php or the the contemplate section (which currently has a major bug and have to wait for a new version).
Sorry, quite new to Drupal, so at a loss on where to add the code to make the specific profile field appear at the bottom of a news (story) article.
So please Nevets, where do I add (step by step please):
and the
if($user->profile_experience):print check_markup($user->profile_experience)endifand just maybe would it be possible to include the user photo on the left of the experience field?
Thank you so much!
Lilian
A couple of approaches
This should work in eiither place though you will need to use $account->profile_experience. So the first part
should go at the top of the template (that way if you want to use another field in $account you do not need to worry if it has been loadedor not).
The second part can be coded as
If there is no html in between and once again in either template goes where you want the information printed.
If you only want this for news (story) and go the node.tpl.php route I would suggest copying node.tpl.php to node-story.tph.php and modifying node-story.tph.php if that is the only place you want the extra information.
As for the picture that may already be handled by the existing node.tpl.php, look for something like
Dear Nevets, Thank you
Dear Nevets,
Thank you kindly for your input .. I'm definitely in the right direction, but currently with the code below it shows somebody else's information, not the person that submitted the press release.
The following is in node.tpl.php
The : in
gives me an error, so I took it out .. is that perhaps why it does not work?
So close, and yet so far ..
Thank you so much Nevets for any help.
Lilian
PS. How do you receive an email whenever there is a reply on the forum? I do not seem to receive anything.
All the best.
Typo on my part
Instead of
please try
Yes! it works fabulously!
Yes! it works fabulously! thank you so much Nevets.
You have been so kind, but if you have a moment .. how would I hide 'Admin' or User 1, as I will be putting up most of the press releases. It would be too much have the profile fields of Admin below every article.
Most appreciated!
Lilian
Is the solution good also for 4.7
I was thinking - why not just use the `Author information' block which you can put at the bottom block? U can pick which profile field along with user picture to appear also
Small change needed
Find the line
and change to
which means the information will only show when viewing a node on a page by itself and when when the nodes author is not user 1.
Nevets, thank you so much!
Nevets, thank you so much! Works perfectly. You are a super star!