Jump to content

Easy way to display the "username" from tblhosting on clientarea?


paperweight

Recommended Posts

Hi: I want to just display the username from the tblhosting on the clientareahome.tpl.

 

I tried these:

{$client.tblhosting.username}

{$tblhosting.username}

 

But neither of the two above work. Is there a simple way to output this field in my template?

 

I also tried this but it doesn't work:

 

{foreach key=num item=service from=$services}
               {$service.username}
{/foreach}

 

Thank you~

Edited by paperweight
Link to comment
Share on other sites

Ok, I solved this by creating a hook. Here's my hook info:

 

 

<?php
use Illuminate\Database\Capsule\Manager as Capsule;

add_hook('ClientAreaPage', 1, function ($vars) {
       $data=Capsule::table('tblhosting')->where('userid',$_SESSION['uid'])->where('domainstatus','Active')->first();
       if($data){
           return array("clientproductusername"=>''.$data->username.'');
       }
});

 

If anyone knows of a simpler way than to use a hook, please let me know :!:

Link to comment
Share on other sites

If anyone knows of a simpler way than to use a hook, please let me know :!:

a hook's going to be the simplest way... I suppose you could write a data feed to do it, but you'd still be querying the database, so you might as well use the hook. :)

 

if this was for a homepagepanel, you could you the Class method instead - but it's still just a hook, so nothing to be gained now you have a working hook.

 

one simple suggestion I would make is that if this variable is only needed in clientareahome, then it would make sense to change the hook from 'ClientAreaPage' to 'ClientAreaPageHome' - that way, the hook will only run on the appropriate page and not on every page on the client area. :idea:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated