Jump to content

cdeese8

Recommended Posts

I'm  just not having much luck, frig! 

Thanks in advance for anything you can share with me to help!

I'd like to display the value field from table tblcustomfieldsvalues in the Client Area Home Panel Active Products/Services on WHMCS 7.4.1 with stock template.

I visit example.com/whmcs/configproducts.php?action=edit&id=40 and put {$cf46} (or even {$customfields.0.value}) in the "Product Name" field so clientarea dashboard home panel will display name and custom field data. If I goto example.com/clientarea.php?action=productdetails&id=999 I see that the data is being display because I put {debug} into the clientareaproductdetails.tpl file. Why am I not able to display custom field id #46 array data in the product name field?

h7ZCeXl.png

image.png.cf40eee2ee592bccd8736b16f259f46e.png

I thought I could tweak the hook from a previous post by brian too, but no good.

<?php

use Illuminate\Database\Capsule\Manager as Capsule;

function display_custom_field_46($vars)
{
   $client = Menu::context('client');
   $cf46 = Capsule::table('tblcustomfieldsvalues')
               ->where('value', $client->id)
               // compare ->where('fieldid', $vars['fieldid'])
               ->get();
   $encodedata = json_encode($cf46);
   $decodedata = json_decode($encodedata, true);
   return array("cf46" => $decodedata);
}
add_hook("ClientAreaPage", 1, "display_custom_field_46");
?>

p.s. - this post too, was not helpful either. i tried copy / paste into hook folder and use custom field #46 but it did not work when I pasted {$customFields[$service.id]} into Product Name field.

Edited by cdeese8
forgot images and update hook with my recent attempt
Link to comment
Share on other sites

16 hours ago, cdeese8 said:

I'd like to display the value field from table tblcustomfieldsvalues in the Client Area Home Panel Active Products/Services on WHMCS 7.4.1 with stock template.

i've created a monster - you're obsessed with making homepagepanels - and now editing existing ones too! lol 👾

16 hours ago, cdeese8 said:

I visit example.com/whmcs/configproducts.php?action=edit&id=40 and put {$cf46} (or even {$customfields.0.value}) in the "Product Name" field so clientarea dashboard home panel will display name and custom field data. If I goto example.com/clientarea.php?action=productdetails&id=999 I see that the data is being display because I put {debug} into the clientareaproductdetails.tpl file.

Why am I not able to display custom field id #46 array data in the product name field?

the panel will be taking it's content from a database query (in one form or another), and by default that won't include getting PCF in the query... the content is not being pulled from another template, nor from Smarty variables - hence why modifying client area arrays will have little effect on the panel.

if you're going to modify an existing panel, you basically need to open it; store the children as an array; loop though that array making your modifications (using PHP) to each child and finally return the panel back to the homepage... although sometimes it can be simpler to just rebuild it from scratch depending on the modifications you intend to make to the output.... you would use a homepagepanels hook for that and have your customfield query in there (though it will need the fieldid to get the correct value).

Link to comment
Share on other sites

I didn't know that by only adding a custom field into the panel output would require so many extra lines of codes. that's madness! jeeze that sounds intense. rebuilding the service home panel seems more complicated than copy pasting a file into a new folder. The existing panel is already just about perfect. Just have to make do.

You know what, with my ignorance, I might just call it quits and end my search here. I'm not ready to burn up an entire supply of lamp oil. Not today, maybe in a week.

Link to comment
Share on other sites

20 hours ago, cdeese8 said:

I didn't know that by only adding a custom field into the panel output would require so many extra lines of codes. that's madness!

welcome to WHMCS. 🤕

I remember saying back with v6 when all this got introduced in 2015, that it would have made more sense for the code that generated these panels/sidebars/navbars to be accessible - at the very least readable, but optionally editable.. that would have made your issue just a minor tweak to existing code... it also would have made learning about them easier as a lot of the example hooks that got written back in the v6 days didn't work... hence why I have mistakenly wasted hours (probably days) of my life posting hooks to show how to do these things.

20 hours ago, cdeese8 said:

rebuilding the service home panel seems more complicated than copy pasting a file into a new folder.

it can be - depends what you need to do with it.

getting the content of an existing panel is simple enough - but often working through the manipulations of the content can be so tedious, that it's simpler to just redo the panel from scratch... assuming that getting the basic original content isn't difficult to reproduce.

20 hours ago, cdeese8 said:

The existing panel is already just about perfect. Just have to make do.

that's not the spirit of adventure that I expect from you! 🦁

Link to comment
Share on other sites

  • 9 months later...

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.

×
×
  • 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