Derfder
Derfder

Reputation: 3324

CodeIgniter anchor function without any string in value

My code right now:

<?php echo anchor('admin/delete_msg/'.$obj->id, 'DELETE MESSAGE', array('onclick' => 'return confirm(\'Are you sure?\');', 'class' => 'delete-button')); ?>

But Iwould liek to use something like:

<?php echo anchor('admin/delete_msg/'.$obj->id, '', array('onclick' => 'return confirm(\'Are you sure?\');', 'class' => 'delete-button')); ?>

So there is no "DELETE MESSAGE" text and I can use image instead.

But if I leave the single quotes empty the link will show up e.g. http://localhost/project

Any advice how to solve that within anchor function and not going via <a href="...?

Upvotes: 0

Views: 1734

Answers (3)

Derfder
Derfder

Reputation: 3324

I have solved it using space like:

<?php echo anchor('admin/delete_msg/'.$obj->id, ' ', array('onclick' => 'return confirm(\'Are you sure?\');', 'class' => 'delete-button')); ?>

Upvotes: 1

Philip
Philip

Reputation: 4592

Don't use the anchor helper. Just pass $obj to the view(html.php)

<a rel="nofollow" onclick="return confirm()" class="btn btn-delete-icon" href="<?php echo site_url('admin/delete_msg/'.$obj->id.'')?>"> &nbsp; </a>

Upvotes: 0

Mudshark
Mudshark

Reputation: 3253

You could use CSS to hide the text and pull in a background image:

.delete-button{
   display: inline-block;
   width: 80px; /* fits background-img width */
   height: 40px; /* fits background-img height */
   text-indent: -9999px;
   background: url('path/to/image') top left no-repeat;
}

Upvotes: 1

Related Questions