SocialEngine Tutorial – Adding dynamic href links from code behind

One thing you might want to do when you’re coding your own modules/widgets is to have a link to another page you might have created within your socialengine site.

You could use the following to add a link inside your index.tpl view file

<a href='http://yoursite.com/yourmodule/yourfunctionname'>Click me</a>

However if you use direct paths such as this you might run into troubles later on if you decide to move your site or share your modules/widgets with other people.

The best way you can generate html links is through using the helper class which is available inside socialengine which is loaded with your view and available from the $this object. The syntax for using this helper class is as follows;

<?php echo $this->htmlLink('your-module-name/the-action-you-want-to-execute','Click me!'); ?>