Jump to content

How to add custom fields in view ticket sidebar?


Peter Butler

Recommended Posts

I can't find any topic regarding this but here I go...

I have added a 'Client Info' section in the sidebar, when viewing the support ticket. 

Screenshot - 

2019-02-18_1215

I edited in /admin/templates/blend/sidebar.tpl and added 2 new fields 'Company' and 'Website'

Screenshot - 

2019-02-19_0855

 

However, I can't get to parse the data of the Company and Website URL field from the client profile.

Can you please help how to parse the data?

Note: I'm not a coder. 🙂

Link to comment
Share on other sites

Hi Peter,

15 hours ago, Peter Butler said:

However, I can't get to parse the data of the Company and Website URL field from the client profile.

because they don't exist in the template - you would need to query the database to create them using a hook... e.g to get the company name of the client..

<?php

# Admin Area Sidebar Get Client's Company Name Hook
# Written by brian! 

use Illuminate\Database\Capsule\Manager as Capsule;

function admin_sidebar_company_name_hook($vars) {

	if ($vars['pagetemplate'] == 'viewticket') {
		$userid = $vars['userid'];
		$results = Capsule::table('tblclients')->where('id',$userid)->value('companyname');
		return array("companyName" => $results);
	}
}
add_hook("AdminAreaPage", 1, "admin_sidebar_company_name_hook");
?>

website URL would be a different matter as I assume for you that's a client custom field ?

Link to comment
Share on other sites

Hi brian,

Thanks so much! I was able to display the company name in the sidebar now - 

2019-02-22_1214

 

I tried editing the code to display the website url but I had no luck.

Here is the edited code:

Quote

<?php

# Admin Area Sidebar Get Client's Company Name Hook
# Written by brian! 

use Illuminate\Database\Capsule\Manager as Capsule;

function admin_sidebar_website_url_hook($vars) {

    if ($vars['pagetemplate'] == 'viewticket') {
        $userid = $vars['userid'];
        $results = Capsule::table('tblclients')->where('id',$userid)->value('websiteUrl1');
        return array("websiteUrl1" => $results);
    }
}
add_hook("AdminAreaPage", 1, "admin_sidebar_website_url_hook");
?>

I get the 'websiteUrl1' name from the custom field and patterned after companyName. So, yeah I guess it's not correct 😄

2019-02-22_1215

 

Only the website url is missing. Thanks for all you help Brian. Really appreciate it. 🙂

Link to comment
Share on other sites

  • 2 years later...
4 hours ago, Md Rasel Khan said:

Could you please tell me how to move the additional tab to left sidebar using hook? https://prnt.sc/10nxsvm

you couldn't move it in the sense of taking the code from one and embedding it in the other - what you would have to do is to create a new sidebar, query the db for the appropriate customfield content and then hide/remove the additional info box from the template.

also, you would have to work out how to handle outputting each type of custom field - e.g., with links, you probably couldn't visually show the URLs as they'd be too long for a sidebar - so you could add a link to them.... and whether you just want one specific field or if you need to show them all.

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