- Posts: 99
- Thank you received: 2
Product plugin loaded by modules
11 years 9 months ago #183069
by gulp
Product plugin loaded by modules was created by gulp
-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.3.6
Hello,
I'm searching for a way to have a better behaviour for the hikashop product plugin.
The problem is due to the core Joomla and the way the system parses content plugins being loaded by modules:
if I create an article and insert a product tag by the plugin button it works fine while the system loads directly the article both for the article page and for a category page.
If the article comes loaded by a module it comes with a different behaviour due to the fact that the module loads the article and the plugin get parsed at last, then if the module have to manage some content of the article cannot recognize it !
I don't know if I've good explained this issue, it's a bit twisted !!
The best is to try to load in a module (like a slider or carousel) some different kind of articles (content articles, with or without the use of hikashop plugin) and see what it's going to happen.
I've also wrote a post in Joomla forum:
forum.joomla.org/viewtopic.php?f=727&t=867802
At present I think that a way to solve is that the "product-button", instead of insert a plugin code, writes directly the correct product content in the article, especially for the picture that is usually the main element of one of this content items.
I know this will lead to some mistake if the product pictures changes ...
What do you think about this solution ?
Do you think is there a better way to solve ?
-- Joomla version -- : 3.3.6
Hello,
I'm searching for a way to have a better behaviour for the hikashop product plugin.
The problem is due to the core Joomla and the way the system parses content plugins being loaded by modules:
if I create an article and insert a product tag by the plugin button it works fine while the system loads directly the article both for the article page and for a category page.
If the article comes loaded by a module it comes with a different behaviour due to the fact that the module loads the article and the plugin get parsed at last, then if the module have to manage some content of the article cannot recognize it !
I don't know if I've good explained this issue, it's a bit twisted !!
The best is to try to load in a module (like a slider or carousel) some different kind of articles (content articles, with or without the use of hikashop plugin) and see what it's going to happen.
I've also wrote a post in Joomla forum:
forum.joomla.org/viewtopic.php?f=727&t=867802
At present I think that a way to solve is that the "product-button", instead of insert a plugin code, writes directly the correct product content in the article, especially for the picture that is usually the main element of one of this content items.
I know this will lead to some mistake if the product pictures changes ...
What do you think about this solution ?
Do you think is there a better way to solve ?
Please Log in or Create an account to join the conversation.
11 years 9 months ago #183081
by gulp
Replied by gulp on topic Product plugin loaded by modules
Could you please suggest what to change in the plugin code to insert directly the html tags (e.g.: the image tag with correct source, the a tag with correct url) instead of the plugin code ?
Please Log in or Create an account to join the conversation.
11 years 9 months ago #183083
by Xavier
Replied by Xavier on topic Product plugin loaded by modules
Hi,
Which plugin exactly are you talking about ? The one which is adding tags in a Joomla article when pressing the "product" button under the wysiwyg area, right ?
So to add the content directly instead of a tag, you have to edit the plugin "plugins\editors-xtd\hikashopproduct\hikashopproduct.php" and in the function "productDisplay()" replace the content of the "document.getElementById('product_insert').value" by the desired HTML.
You will have to load the full product data, etc. So PHP knowledges are required.
Which plugin exactly are you talking about ? The one which is adding tags in a Joomla article when pressing the "product" button under the wysiwyg area, right ?
So to add the content directly instead of a tag, you have to edit the plugin "plugins\editors-xtd\hikashopproduct\hikashopproduct.php" and in the function "productDisplay()" replace the content of the "document.getElementById('product_insert').value" by the desired HTML.
You will have to load the full product data, etc. So PHP knowledges are required.
Please Log in or Create an account to join the conversation.
11 years 9 months ago #183340
by gulp
Replied by gulp on topic Product plugin loaded by modules
Ok thank you, I'll do this way !
Please Log in or Create an account to join the conversation.
11 years 9 months ago #183539
by gulp
Replied by gulp on topic Product plugin loaded by modules
Could you tell me how to retrieve the correct path of the images (and thumbs) related to product and set into the field #__hikashop_file.file_path ?
Thank you !
Thank you !
Please Log in or Create an account to join the conversation.
11 years 9 months ago #183558
by Xavier
Replied by Xavier on topic Product plugin loaded by modules
Hi,
This kind of code should do the job:
This kind of code should do the job:
Code:
$product_id = 1;
$fileClass = hikashop_get('class.file');
$startPath = $fileClass->getPath('image');
$db = JFactory::getDBO();
$db->setQuery('SELECT file_path FROM '.hikashop_table('file').' WHERE file_type = "product" and file_ref_id = '.(int)$product_id.' LIMIT 1');
$endPath = $db->loadResult();
$fullPath = $startPath.$endPath;
Please Log in or Create an account to join the conversation.
11 years 9 months ago - 11 years 9 months ago #183803
by gulp
Replied by gulp on topic Product plugin loaded by modules
The call
returns the path like:
but:
- I'm searching for the thumb file, not the full image. How are the thumbs created by hikashop mapped by the source image ? These are usually located under thumbnails/166x250/, but how the system knows it ?
- to put the image in the editor I've to create the full URL path, how to convert URI to URL ?
Thank you for your help !
Code:
$fileClass->getPath('image')
Code:
C:\web\mysite\web\media\com_hikashop\upload\
- I'm searching for the thumb file, not the full image. How are the thumbs created by hikashop mapped by the source image ? These are usually located under thumbnails/166x250/, but how the system knows it ?
- to put the image in the editor I've to create the full URL path, how to convert URI to URL ?
Thank you for your help !
Last edit: 11 years 9 months ago by gulp.
Please Log in or Create an account to join the conversation.
11 years 9 months ago #183805
by Xavier
Replied by Xavier on topic Product plugin loaded by modules
Hi,
The following code is more appropriate if you want to display thumbnails.
It will write directly the image HTML tag.
The following code is more appropriate if you want to display thumbnails.
Code:
$product_id = 1;
$db = JFactory::getDBO();
$db->setQuery('SELECT file_path FROM '.hikashop_table('file').' WHERE file_type = "product" and file_ref_id = '.(int)$product_id.' LIMIT 1');
$path = $db->loadResult();
$imageHelper = hikashop_get('helper.image');
$imageHelper->width = '100';
$imageHelper->height = '100';
echo $imageHelper->displayThumbnail($path);
Please Log in or Create an account to join the conversation.
11 years 9 months ago #183884
by gulp
Replied by gulp on topic Product plugin loaded by modules
I'm sorry but it is not clear what do you mean with thumbnails:
those images that the plugin is already using aren't created runtime, but during the upload of the main image of the product and has this path:
media/com_hikashop/upload/thumbnails/166x250/
instead of which it creates with your last code that are here:
media/com_hikashop/upload/thumbnail_166x250/
I just would like to load the already created thumbnails as in first path, then I'm wondering how to retrieve that path !
those images that the plugin is already using aren't created runtime, but during the upload of the main image of the product and has this path:
media/com_hikashop/upload/thumbnails/166x250/
instead of which it creates with your last code that are here:
media/com_hikashop/upload/thumbnail_166x250/
I just would like to load the already created thumbnails as in first path, then I'm wondering how to retrieve that path !
Please Log in or Create an account to join the conversation.
11 years 9 months ago #183887
by Xavier
Replied by Xavier on topic Product plugin loaded by modules
Hi,
If all the thumbnails are created in the same folder (it depends on your images settings in Configuration > Main > Image), so you can just use that code:
If all the thumbnails are created in the same folder (it depends on your images settings in Configuration > Main > Image), so you can just use that code:
Code:
$product_id = 1;
$db = JFactory::getDBO();
$db->setQuery('SELECT file_path FROM '.hikashop_table('file').' WHERE file_type = "product" and file_ref_id = '.(int)$product_id.' LIMIT 1');
$endPath = $db->loadResult();
$fullPath = 'media/com_hikashop/upload/thumbnails/166x250/'.$endPath;
Please Log in or Create an account to join the conversation.
11 years 9 months ago #184088
by gulp
Replied by gulp on topic Product plugin loaded by modules
Then there is now way to check which is the correct path ?
How does the code knows that the path is this : 'media/com_hikashop/upload/thumbnails/166x250/' ?
How does the code knows that the path is this : 'media/com_hikashop/upload/thumbnails/166x250/' ?
Please Log in or Create an account to join the conversation.
11 years 9 months ago #184114
by Xavier
Replied by Xavier on topic Product plugin loaded by modules
Hi,
The system know that based on your images settings in Configuration > Main > Images.
Based on the sizes set and the crop method it generate the thumbnails in the folder of the correct thumbnail size. So based on your settings, the thumbnail path will always be the same
The system know that based on your images settings in Configuration > Main > Images.
Based on the sizes set and the crop method it generate the thumbnails in the folder of the correct thumbnail size. So based on your settings, the thumbnail path will always be the same
Please Log in or Create an account to join the conversation.
Time to create page: 0.249 seconds