Replacing variable in an html link with an attribute

Permalink
This might be an easy question, but I'm stumped.

I'm trying to figure out how to take the value this provides,

$ownerName = $ui->getUserName(); //get the username of the page owner

and insert it into the spot that says [VARIABLE] here:

<h2><a href="http://site.com/store/[VARIABLE]">Simple text link to store</a></h2>

(The code will be in an html block in page defaults, so that the value is automatically filled when a new page is created)

pkpadmin
 
DAkers replied on at Permalink Reply
You could echo out the html in php

<?php
echo '<h2><a href="http://site.com/store/' . $ownerName . '">Simple text link to store</a></h2>';
?>
pkpadmin replied on at Permalink Reply
pkpadmin
Thanks. I tried it. I also tried

<?php
echo '<h2><a href="http://site.com/store/'$value = $ui->getAttribute('.$ownerName.'); '">Simple text link to store</a></h2>

I don't know if its working. Shouldn't the output in the browser be populated with the value? I just see whatever happens to be afterhttp://site.com/store/, exactly as entered.
DAkers replied on at Permalink Reply
Your other version has some errors in it. The one I supplied should work fine if you have this variable

$ownerName = $ui->getUserName();

Are any errors coming up?

If you want to test that this variable is getting the correct data. Try just echo out the variable:

echo $ownerName;


If it works, you should see your user name in your content.
pkpadmin replied on at Permalink Reply
pkpadmin
Thanks for your help. Got me in the right direction. This finally worked! I put this in a php block.
$ownerID = $c->getCollectionUserID();
$ui = UserInfo::getByID($ownerID);
$ownerName = $ui->getUserName();
?>
<html>
<h2><a href="http://site.com/store/<?php echo $ownerName ?>">Simple text link to store</a></h2>
pkpadmin replied on at Permalink Reply
pkpadmin
To use the Owner ID instead of the Owner name, simply put $ownerID instead in the URL.