[Skip to main content](#vessel-content)

#   Database Call from custom html module

##

- **[dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile")**
- [![dynamicvitality's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile") Topic Author
- [ Offline](/forum/user/8140-dynamicvitality)

Less More

- Posts: 35
- Thank you received: 2
-
-

13 years 9 months ago [\#85169](#85169) by [dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile")  *[Database Call from custom html module](/forum/4-how-to/77396-database-call-from-custom-html-module#85169 "Long story short, I am severely editing the product display page. I need to call upon the description (or else a custom field that is a replica of the description) in a custom html module on the same page.  These gives me the following error: row-&gt;product&#95;centers&#95;description; ?&gt;  or  element-&gt;product&#95;description)); ?&gt;  ERROR: Fatal error: Using $this when not in object context in....  However, I can call upon it individually as shown below without errors, though that won't work because I can't make a new custom html for every single product page:  get(2); echo $prod-&gt;product&#95;centers&#95;description; ?&gt;  Please help, G")* was created by *[dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile")*

Long story short, I am severely editing the product display page. I need to call upon the description (or else a custom field that is a replica of the description) in a custom html module on the same page.

These gives me the following error:
&lt;?php echo $this-&gt;row-&gt;product_centers_description; ?&gt;

or

&lt;?php echo $this-&gt;element-&gt;product_description)); ?&gt;

ERROR: Fatal error: Using $this when not in object context in....

However, I can call upon it individually as shown below without errors, though that won't work because I can't make a new custom html for every single product page:

&lt;?php $class = hikashop_get('class.product');
$prod = $class-&gt;get(2);
echo $prod-&gt;product_centers_description; ?&gt;

Please help,
G

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzc3Mzk2LWRhdGFiYXNlLWNhbGwtZnJvbS1jdXN0b20taHRtbC1tb2R1bGU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26395
- Thank you received: 4077
-
- [](http://obsi.dev)
-

13 years 9 months ago [\#85266](#85266) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Database Call from custom html module](/forum/4-how-to/77396-database-call-from-custom-html-module#85266 "Long story short, I am severely editing the product display page. I need to call upon the description (or else a custom field that is a replica of the description) in a custom html module on the same page.  These gives me the following error: row-&gt;product&#95;centers&#95;description; ?&gt;  or  element-&gt;product&#95;description)); ?&gt;  ERROR: Fatal error: Using $this when not in object context in....  However, I can call upon it individually as shown below without errors, though that won't work because I can't make a new custom html for every single product page:  get(2); echo $prod-&gt;product&#95;centers&#95;description; ?&gt;  Please help, G")*

Hi,

I did not understand your message but the PHP code in modules is not the same than in views.
It is not possible to copy/past code in views directly in a module, the context is completely different.
After that, I don't know where you put your code so it is difficult to help you.

A module could be call in the product page but the module should read the product id directly in the url.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzc3Mzk2LWRhdGFiYXNlLWNhbGwtZnJvbS1jdXN0b20taHRtbC1tb2R1bGU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile")**
- [![dynamicvitality's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile") Topic Author
- [ Offline](/forum/user/8140-dynamicvitality)

Less More

- Posts: 35
- Thank you received: 2
-
-

13 years 9 months ago -  13 years 9 months ago [\#85293](#85293) by [dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile")  Replied by *[dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile")* on topic *[Database Call from custom html module](/forum/4-how-to/77396-database-call-from-custom-html-module#85293 "Long story short, I am severely editing the product display page. I need to call upon the description (or else a custom field that is a replica of the description) in a custom html module on the same page.  These gives me the following error: row-&gt;product&#95;centers&#95;description; ?&gt;  or  element-&gt;product&#95;description)); ?&gt;  ERROR: Fatal error: Using $this when not in object context in....  However, I can call upon it individually as shown below without errors, though that won't work because I can't make a new custom html for every single product page:  get(2); echo $prod-&gt;product&#95;centers&#95;description; ?&gt;  Please help, G")*

Can you show me, using the bottom code as a rough draft, how to call on "product_centers_description" using the ID directly from the URL? I really appreciate how excellent the customer service is around here. Thank you.

Let me simplify:

I need this code...

&lt;?php $class = hikashop_get('class.product');
$prod = $class-&gt;get(1);
echo $prod-&gt;product_centers_description; ?&gt;

To pull the "get(id)" from the url or some other way than "$this", because $this gives me errors:

[ retreatwell.com/index.php?option=com\_hik...yout=show&amp;Itemid=274](http://retreatwell.com/index.php?option=com_hikashop&view=product&layout=show&Itemid=274)

Last edit: 13 years 9 months ago by [dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzc3Mzk2LWRhdGFiYXNlLWNhbGwtZnJvbS1jdXN0b20taHRtbC1tb2R1bGU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26395
- Thank you received: 4077
-
- [](http://obsi.dev)
-

13 years 9 months ago [\#85444](#85444) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Database Call from custom html module](/forum/4-how-to/77396-database-call-from-custom-html-module#85444 "Long story short, I am severely editing the product display page. I need to call upon the description (or else a custom field that is a replica of the description) in a custom html module on the same page.  These gives me the following error: row-&gt;product&#95;centers&#95;description; ?&gt;  or  element-&gt;product&#95;description)); ?&gt;  ERROR: Fatal error: Using $this when not in object context in....  However, I can call upon it individually as shown below without errors, though that won't work because I can't make a new custom html for every single product page:  get(2); echo $prod-&gt;product&#95;centers&#95;description; ?&gt;  Please help, G")*

Hi,

You can load the product id using this code: Code:

$product_id = (int)hikashop_getCID('product_id'); if(empty($product_id)) { $menus = $app-&gt;getMenu(); $menu = $menus-&gt;getActive(); if(empty($menu)){ global $Itemid; if(!empty($Itemid)){ $menus-&gt;setActive($Itemid); $menu = $menus-&gt;getItem($Itemid); } } if (is_object( $menu )) { jimport('joomla.html.parameter'); $category_params = new HikaParameter( $menu-&gt;params ); $product_id = $category_params-&gt;get('product_id'); } }

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzc3Mzk2LWRhdGFiYXNlLWNhbGwtZnJvbS1jdXN0b20taHRtbC1tb2R1bGU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile")**
- [![dynamicvitality's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile") Topic Author
- [ Offline](/forum/user/8140-dynamicvitality)

Less More

- Posts: 35
- Thank you received: 2
-
-

13 years 9 months ago -  13 years 9 months ago [\#85491](#85491) by [dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile")  Replied by *[dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile")* on topic *[Database Call from custom html module](/forum/4-how-to/77396-database-call-from-custom-html-module#85491 "Long story short, I am severely editing the product display page. I need to call upon the description (or else a custom field that is a replica of the description) in a custom html module on the same page.  These gives me the following error: row-&gt;product&#95;centers&#95;description; ?&gt;  or  element-&gt;product&#95;description)); ?&gt;  ERROR: Fatal error: Using $this when not in object context in....  However, I can call upon it individually as shown below without errors, though that won't work because I can't make a new custom html for every single product page:  get(2); echo $prod-&gt;product&#95;centers&#95;description; ?&gt;  Please help, G")*

So combing the two would look something like this:
Code:

$product_id = (int)hikashop_getCID('product_id'); if(empty($product_id)) { $menus = $app-&gt;getMenu(); $menu = $menus-&gt;getActive(); if(empty($menu)){ global $Itemid; if(!empty($Itemid)){ $menus-&gt;setActive($Itemid); $menu = $menus-&gt;getItem($Itemid); } } if (is_object( $menu )) { jimport('joomla.html.parameter'); $category_params = new HikaParameter( $menu-&gt;params ); $product_id = $category_params-&gt;get('product_id'); } } $productClass = hikashop_get('class.product'); $prod = $productClass-&gt;get($product_id); echo $prod-&gt;product_centers_description;

Last edit: 13 years 9 months ago by [Jerome](/forum/user/80-jerome "View Jerome's Profile"). Reason: Fixing the code

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzc3Mzk2LWRhdGFiYXNlLWNhbGwtZnJvbS1jdXN0b20taHRtbC1tb2R1bGU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26395
- Thank you received: 4077
-
- [](http://obsi.dev)
-

13 years 9 months ago [\#85498](#85498) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Database Call from custom html module](/forum/4-how-to/77396-database-call-from-custom-html-module#85498 "Long story short, I am severely editing the product display page. I need to call upon the description (or else a custom field that is a replica of the description) in a custom html module on the same page.  These gives me the following error: row-&gt;product&#95;centers&#95;description; ?&gt;  or  element-&gt;product&#95;description)); ?&gt;  ERROR: Fatal error: Using $this when not in object context in....  However, I can call upon it individually as shown below without errors, though that won't work because I can't make a new custom html for every single product page:  get(2); echo $prod-&gt;product&#95;centers&#95;description; ?&gt;  Please help, G")*

Hi,

I have fixed your code.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

The following user(s) said Thank You: [dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzc3Mzk2LWRhdGFiYXNlLWNhbGwtZnJvbS1jdXN0b20taHRtbC1tb2R1bGU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile")**
- [![dynamicvitality's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile") Topic Author
- [ Offline](/forum/user/8140-dynamicvitality)

Less More

- Posts: 35
- Thank you received: 2
-
-

13 years 9 months ago [\#85506](#85506) by [dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile")  Replied by *[dynamicvitality](/forum/user/8140-dynamicvitality "View dynamicvitality's Profile")* on topic *[Database Call from custom html module](/forum/4-how-to/77396-database-call-from-custom-html-module#85506 "Long story short, I am severely editing the product display page. I need to call upon the description (or else a custom field that is a replica of the description) in a custom html module on the same page.  These gives me the following error: row-&gt;product&#95;centers&#95;description; ?&gt;  or  element-&gt;product&#95;description)); ?&gt;  ERROR: Fatal error: Using $this when not in object context in....  However, I can call upon it individually as shown below without errors, though that won't work because I can't make a new custom html for every single product page:  get(2); echo $prod-&gt;product&#95;centers&#95;description; ?&gt;  Please help, G")*

Awesome!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzc3Mzk2LWRhdGFiYXNlLWNhbGwtZnJvbS1jdXN0b20taHRtbC1tb2R1bGU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.058 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
