- Posts: 7
- Thank you received: 0
File Download Link in listing_img_title.php
12 years 6 months ago #150974
by scrapper
File Download Link in listing_img_title.php was created by scrapper
Hi, I am trying to display certain text "True" if the downloadable files exists for this product on the product/listing_img_title view, I am using following php code.
Please let me know where I have gone wrong.
For some reasons I am not able to use anything from $this->element in listing_img_title.php.
I have also tried following but still no luck.
Please help me fix this issue.
Please let me know where I have gone wrong.
Code:
<?php
if ($this->element->files) {
echo "True";
}
echo $this->element->product_code;
if (!empty ($this->element->product_url)) {
echo JText :: sprintf('MANUFACTURER_URL', '<a href="' . $this->element->product_url . '" target="_blank">' . $this->element->product_url . '</a>');
}
?>
For some reasons I am not able to use anything from $this->element in listing_img_title.php.
I have also tried following but still no luck.
Code:
<?php
if(!empty($this->element->extraData->bottomMiddle))
echo implode("\r\n",$this->element->extraData->bottomMiddle);
if(!empty($this->element->extraData->bottomEnd))
echo implode("\r\n",$this->element->extraData->bottomEnd); ?>
Please help me fix this issue.
Please Log in or Create an account to join the conversation.
12 years 6 months ago #150994
by nicolas
Replied by nicolas on topic File Download Link in listing_img_title.php
Hi,
First, in listing_img_title, it's not $this->element but $this->row that you want to use.
Second, there are no files and no extra data loaded in that view file since there is no need to load the files data of the products in listings.
This means that you'll have to write a SQL query in order to load the files of the products yourself from the hikashop_file table.
First, in listing_img_title, it's not $this->element but $this->row that you want to use.
Second, there are no files and no extra data loaded in that view file since there is no need to load the files data of the products in listings.
This means that you'll have to write a SQL query in order to load the files of the products yourself from the hikashop_file table.
Please Log in or Create an account to join the conversation.
12 years 6 months ago - 12 years 6 months ago #151026
by scrapper
Replied by scrapper on topic File Download Link in listing_img_title.php
This does not work for me.
I tried to print the row array with its data, but I dont see file download arrays anywhere. see blow.
I get following result with above php, I dont see downloadable file arrays.
My question is how I can access the file download array elements in Hikashop listing_img_title view.
For example I want to echo a text "True" if free downloadable file exists for a product.
Please help
I tried to print the row array with its data, but I dont see file download arrays anywhere. see blow.
Code:
<?php
ini_set('xdebug.var_display_max_data', 0);
echo '<pre>';
print_r($this->row);
echo '</pre>';?>
I get following result with above php, I dont see downloadable file arrays.
Code:
stdClass Object
(
[product_id] => 260
[product_parent_id] => 0
[product_name] => Networking & O/S installation Services
[product_description] =>
Professional services that includes networking installation, troubleshooting, configuration and installation of operating systems across the entire network.
[product_quantity] => -1
[product_code] => networking-os-installation
[product_published] => 1
[product_hit] => 53
[product_created] => 1378243587
[product_sale_start] => 0
[product_sale_end] => 0
[product_delay_id] => 0
[product_tax_id] => 0
[product_type] => main
[product_vendor_id] => 0
[product_manufacturer_id] => 0
[product_url] =>
[product_weight] => 0.000
[product_keywords] =>
[product_weight_unit] => kg
[product_modified] => 1378243587
[product_meta_description] =>
[product_dimension_unit] => m
[product_width] => 0.000
[product_length] => 0.000
[product_height] => 0.000
[product_max_per_order] => 0
[product_access] => all
[product_group_after_purchase] =>
[product_min_per_order] => 0
[product_contact] => 0
[product_last_seen_date] => 1396391193
[product_sales] => 1
[product_waitlist] => 0
[product_layout] =>
[product_average_score] => 0
[product_total_vote] => 0
[product_page_title] =>
[product_alias] =>
[product_price_percentage] => 0.0000000
[product_msrp] => 0.0000000
[product_canonical] =>
[cond] => used
[alias] => networking-o-s-installation-services
[file_id] => 766
[file_name] =>
[file_description] =>
[file_path] => computer-networking.jpg
[file_type] => product
[file_ref_id] => 260
[file_free_download] => 0
[file_ordering] => 0
[file_limit] => 0
[prices] => Array
(
[0] => stdClass Object
(
[price_id] => 243
[price_currency_id] => 4
[price_product_id] => 260
[price_value] => 500.00000
[price_min_quantity] => 0
[price_access] => all
[price_value_with_tax] => 500.00000
[taxes] => Array
(
)
)
)
[badges] => Array
(
)
)
My question is how I can access the file download array elements in Hikashop listing_img_title view.
For example I want to echo a text "True" if free downloadable file exists for a product.
Code:
<?php
if (array_key_exists($this->row->downloadable_file)) {
echo "True";
}
echo $this->row->downloadable_file;
?>
</div>
Please help
Last edit: 12 years 6 months ago by scrapper. Reason: more detailed explanation
Please Log in or Create an account to join the conversation.
12 years 5 months ago #151045
by nicolas
Replied by nicolas on topic File Download Link in listing_img_title.php
You say it doesn't work, but it does. You can the product data, which was not the case with $this->element.
Now as I said in my previous email, the files data is not load on that view file since it is not needed. So you need to load it yourself from the database with a mysql query on the hikashop_file table. You cannot access it directly in PHP as it's not loaded by HikaShop there.
Now as I said in my previous email, the files data is not load on that view file since it is not needed. So you need to load it yourself from the database with a mysql query on the hikashop_file table. You cannot access it directly in PHP as it's not loaded by HikaShop there.
Please Log in or Create an account to join the conversation.
12 years 5 months ago #151225
by scrapper
Replied by scrapper on topic File Download Link in listing_img_title.php
Is it not possible to load the same php code in img_title.php which is loaded with show_block_product_files? This way I can use it with img_title.php. But the problem is I dont know how to do it.
Regarding I have to load it by myself from the database with a mysql query on the hikashop_file table. I am new to PHP and mysql and I dont know where to start. please help.
Regarding I have to load it by myself from the database with a mysql query on the hikashop_file table. I am new to PHP and mysql and I dont know where to start. please help.
Please Log in or Create an account to join the conversation.
12 years 5 months ago - 12 years 5 months ago #151344
by scrapper
Replied by scrapper on topic File Download Link in listing_img_title.php
Bump!!!
nicolas, if you help me with this issue. I will paint your face on the surface of the moon or probably I will consider you a very good human being the one who likes to help others. Perhaps I will print posters with your face on it and slogan that Nicolas is a great man and a helping hand.
So, nicolas, please help me with this. How can I echo True in listing_img_title.php if downloadable file exists. Or if possible how can I show the download link to the file in listing_img_title.php page.
I will send you the sample of the poster when I finish designing it. Thank you Nicolas
nicolas, if you help me with this issue. I will paint your face on the surface of the moon or probably I will consider you a very good human being the one who likes to help others. Perhaps I will print posters with your face on it and slogan that Nicolas is a great man and a helping hand.
So, nicolas, please help me with this. How can I echo True in listing_img_title.php if downloadable file exists. Or if possible how can I show the download link to the file in listing_img_title.php page.
I will send you the sample of the poster when I finish designing it. Thank you Nicolas
Last edit: 12 years 5 months ago by scrapper.
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
12 years 5 months ago #151362
by Mohamed Thelji
Replied by Mohamed Thelji on topic File Download Link in listing_img_title.php
Hello,
Using this kind of code to load your product files information will probably do the job :
Using this kind of code to load your product files information will probably do the job :
Code:
$this->database = JFactory::getDBO();
$query='SELECT * FROM '.hikashop_table('file').' WHERE file_ref_id ='.$YOURPRODUCTID;
$this->database->setQuery($query);
$product_files = $this->database->loadObjectList();
The following user(s) said Thank You: scrapper
Please Log in or Create an account to join the conversation.
12 years 5 months ago #151660
by scrapper
Replied by scrapper on topic File Download Link in listing_img_title.php
Nicolas you are a good man. thank you for the help.
Please Log in or Create an account to join the conversation.
Time to create page: 0.174 seconds