I've got CCK and Contemplate running beautifully to create a very simple node on my site where users can list songs they're listening to.

In the sidebar (generated with the CCK theme wizard only), everything displays as I'd like: song title is a link to the node, and the author's name is a link to their profile.

However, in the teaser list of all the entries AND on the actual node body itself (generated with contemplate), the author's name is just the name. I'm calling this using <?php print $name ?>, and it IS printing the name, but it's not creating the link back to their profile.

A full look at the code of the teaser template:

<div class="headphones-head">
    <?php foreach ((array)$field_band as $item) { ?>
by <?php print $item['view'] ?>
    <?php } ?>
</div>

<div class="headphones_block-name">
 listened to by <b><?php print $name ?></b> on 
    <?php foreach ((array)$field_right_now as $item) { ?>
<?php print $item['view'] ?>
    <?php } ?>
</div>

What am I doing wrong?

Examples:

(sidebar is viewable on every page, it's titled "in my headphones)

Teaser list: http://www.punkplanet.com/in_my_headphones

Node Body: http://www.punkplanet.com/paul_m_davis/in_my_headphones/pocket_calculator

Comments

sinker’s picture

Duh, my head is foggy--my son kept me up for much of the night.

The sidebar is generated in VIEWS, not straight CCK. I mean the VIEWS theme wizard. Duh!

schwa’s picture

You can code the link into your teaser template:

listened to by <b><a href="?q=<?php print $uid ?>"><?php print $name ?></a></b> on 
sinker’s picture

That's close, but it's returning a url like this:

http://www.punkplanet.com/in_my_headphones/?q=123 which, of course is invalid.

I can stick a quick ./ in place of that ?q= (which I also don't need 'cause I use clean URLs) and it returns what SHOULD point to a user ID, but I'm using pathauto to swap up user IDs with user names so, for instance, Paul M Davis (username) is at http://www.punkplanet.com/paul_m_davis

So the obvious thing to do would be this, right?

listened to by <b><a href="./<?php print $name ?>"><?php print $name ?></a></b> on

And that brings a person to what SHOULD be the right spot and, for some users with single word names IS their profile, but for names with spaces it returns invalid as invalid because the spaces show up in the URL too.

Ideas?

schwa’s picture

Yep, makes perfect sense. Haven't used the pathauto mod myself, but you should be able to find out how to code your links with whatever variable pathauto spits out for $name (the pathauto=ized name variable, as it were) via the Issues queue for that module. Others will likely know more. Good luck!

greggles’s picture

Hi, I was directed here from the pathauto issue queue but wanted to reply here in addition to in the issue queue, because there's another non-pathauto tip: the l function!

listened to by <b> <?php l($name,pathauto_cleanstring($name)) ?></b>

I think that's more or less what you'll want. The benefit of the l function is that it will handle clean urls or not automatically and can also provide the fully qualified domain name and path to the page even if you move your site to a new host. Neat, huh? It saves tons of manual work.

--
Knaddisons Denver Life | mmm Free Range Burritos