- Posts: 35
- Thank you received: 2
Database Call from custom html module
- dynamicvitality
-
Topic Author
- Offline
Less
More
13 years 8 months ago #85169
by dynamicvitality
Database Call from custom html module was created by dynamicvitality
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:
<?php echo $this->row->product_centers_description; ?>
or
<?php echo $this->element->product_description)); ?>
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:
<?php $class = hikashop_get('class.product');
$prod = $class->get(2);
echo $prod->product_centers_description; ?>
Please help,
G
These gives me the following error:
<?php echo $this->row->product_centers_description; ?>
or
<?php echo $this->element->product_description)); ?>
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:
<?php $class = hikashop_get('class.product');
$prod = $class->get(2);
echo $prod->product_centers_description; ?>
Please help,
G
Please Log in or Create an account to join the conversation.
13 years 8 months ago #85266
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Database Call from custom html module
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,
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 & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- dynamicvitality
-
Topic Author
- Offline
Less
More
- Posts: 35
- Thank you received: 2
13 years 8 months ago - 13 years 8 months ago #85293
by dynamicvitality
Replied by dynamicvitality on topic Database Call from custom html module
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...
<?php $class = hikashop_get('class.product');
$prod = $class->get(1);
echo $prod->product_centers_description; ?>
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&Itemid=274
Let me simplify:
I need this code...
<?php $class = hikashop_get('class.product');
$prod = $class->get(1);
echo $prod->product_centers_description; ?>
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&Itemid=274
Last edit: 13 years 8 months ago by dynamicvitality.
Please Log in or Create an account to join the conversation.
13 years 8 months ago #85444
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Database Call from custom html module
Hi,
You can load the product id using this code:
Regards,
You can load the product id using this code:
Code:
$product_id = (int)hikashop_getCID('product_id');
if(empty($product_id)) {
$menus = $app->getMenu();
$menu = $menus->getActive();
if(empty($menu)){
global $Itemid;
if(!empty($Itemid)){
$menus->setActive($Itemid);
$menu = $menus->getItem($Itemid);
}
}
if (is_object( $menu )) {
jimport('joomla.html.parameter');
$category_params = new HikaParameter( $menu->params );
$product_id = $category_params->get('product_id');
}
}
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- dynamicvitality
-
Topic Author
- Offline
Less
More
- Posts: 35
- Thank you received: 2
13 years 8 months ago - 13 years 8 months ago #85491
by dynamicvitality
Replied by dynamicvitality on topic Database Call from custom html module
So combing the two would look something like this:
Code:
$product_id = (int)hikashop_getCID('product_id');
if(empty($product_id)) {
$menus = $app->getMenu();
$menu = $menus->getActive();
if(empty($menu)){
global $Itemid;
if(!empty($Itemid)){
$menus->setActive($Itemid);
$menu = $menus->getItem($Itemid);
}
}
if (is_object( $menu )) {
jimport('joomla.html.parameter');
$category_params = new HikaParameter( $menu->params );
$product_id = $category_params->get('product_id');
}
}
$productClass = hikashop_get('class.product');
$prod = $productClass->get($product_id);
echo $prod->product_centers_description;
Last edit: 13 years 8 months ago by Jerome. Reason: Fixing the code
Please Log in or Create an account to join the conversation.
13 years 8 months ago #85498
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Database Call from custom html module
Hi,
I have fixed your code.
Regards,
I have fixed your code.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
The following user(s) said Thank You: dynamicvitality
Please Log in or Create an account to join the conversation.
- dynamicvitality
-
Topic Author
- Offline
Less
More
- Posts: 35
- Thank you received: 2
13 years 8 months ago #85506
by dynamicvitality
Replied by dynamicvitality on topic Database Call from custom html module
Awesome!
Please Log in or Create an account to join the conversation.
Time to create page: 0.196 seconds