Post by jsweb » Thu Nov 23, 2017 9:36 pm

I am using Opencart Version 2.3.0.2 and I want the ability for clients to upload and link to PDF files not just images via the rich text editor/file manager. The default Summernote editor doesn't seem to give many options and it strips out tags so I have tried a couple of CK Editor extensions (4.7.3 and also Cl!cker Replace Summernote with CKEditor - OC 2.x) in the hope that one of them would allow PDFs to be uploaded and linked to via the file manager but neither of them seem to work properly. The support seems to say I should purchase another extension to enable PDF uploads which I don't really want to do as previous versions have always allowed linking to PDF files without the need to pay extra.

I have managed to edit the filemanager.php file so that it allows pdf files to be uploaded by adding pdf file extension to line 48:
$files = glob($directory . '/' . $filter_name . '*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF.pdf,PDF}', GLOB_BRACE);
and also adding it here:
// Allowed file extension types
$allowed = array(
'jpg',
'jpeg',
'gif',
'png',
'pdf'
);

if (!in_array(utf8_strtolower(utf8_substr(strrchr($filename, '.'), 1)), $allowed)) {
$json['error'] = $this->language->get('error_filetype');
}

// Allowed file mime types
$allowed = array(
'image/jpeg',
'image/pjpeg',
'image/png',
'image/x-png',
'image/gif',
'application/pdf'
);
This does seem to allow pdf files to be uploaded but the problem I have is that the uploaded files cannot be seen in the thumbnail overview that is created by the filemanager as presumably I need some extra changes to the PHP to enable the PDF files to be seen. I have seen this done in earlier versions of the filemanager.php but the code looks quite different so can anyone point me in the right direction? I have a pdf icon already in place in the image folder I just need a way to create an overview of PDF files using that as a thumb. Then hopefully the files will be visible in the image manager and the client can then select them so the link URL is automatically filled in for them.

Newbie

Posts

Joined
Thu Nov 23, 2017 9:23 pm

Post by IP_CAM » Mon Nov 27, 2017 3:36 am

... can anyone point me in the right direction?

Well, nobody seems to be willing to assist for free, just because it came for free
for older OC-Versions, but if you need it anyway, for a lousy 20 Bucks, it's all yours! ::)
---
Enhanced Summernote File Browser & Uploader OC v.2.3.0.0 - 2.3.0.2:
FEATURES:
Add PDF, Video, MP3 & Zip Files
Insert Font-Awesome Icons
Additional Google Fonts
View More Images (24 instead of 16)
Multiple Upload & add Image to Product
Draggable/Sortable Additional Images
Remember Last Folder
Breadcrumb Navigation
Image Crop & Rotate
Select Summernote Theme
Select Codemirror Theme
Grid and List views
---
https://www.opencart.com/index.php?rout ... n_id=29701
---
Or then, try to use something like this, and invest some free time and knowledge, to
make this free Mod work for your Version:
---
Upload Video file PDF file with images in product add images OC v.2.2.0.0
You can upload video as well as pdf file in admin product page while you are
adding more images in image tab. also you can check video file and pdf file
play as well as image at front product page.
---
https://www.opencart.com/index.php?rout ... n_id=27763
---
Good Luck!
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by berka.pavel » Tue Apr 10, 2018 10:51 pm

admin/controller/common/filemanager.pdf
---

Code: Select all

		// Get files
		$files = glob($directory . '/' . $filter_name . '*.{jpg,jpeg,png,gif,pdf,JPG,JPEG,PNG,GIF,PDF}', GLOB_BRACE);
		
		...
		
				// Allowed file extension types
				$allowed = array(
					'jpg',
					'jpeg',
					'gif',
					'png',
					'pdf'
				);
				
				...
				
				// Allowed file mime types
				$allowed = array(
					'image/jpeg',
					'image/pjpeg',
					'image/png',
					'image/x-png',
					'image/gif',
					'application/pdf'
				);
admin/view/template/common/filemanager.tpl
---

Code: Select all

          <?php if ($image['type'] == 'image') { ?>
          <a href="<?php echo $image['href']; ?>" class="thumbnail"><img src="<?php echo (substr($image['name'], -4) != '.pdf') ? $image['thumb'] : '/image/catalog/pdf.jpg'; ?>" alt="<?php echo $image['name']; ?>" title="<?php echo $image['name']; ?>" /></a>
          <label>
            <input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
            <?php echo $image['name']; ?></label>
          <?php } ?>
          
          ...
          
	if ($(this).attr('href').slice(-4) !== ".pdf" ) {
		var img = document.createElement('img');
		img.src = $(this).attr('href');
	} else {
		var img = document.createElement('a');
		img.href = $(this).attr('href');
		img.appendChild(document.createTextNode($('img', this).attr('title')));
		img.target = "_blank";
	}
this works for me

Newbie

Posts

Joined
Sun Oct 16, 2011 11:40 pm

Post by nameispalmer » Thu May 17, 2018 8:09 pm

Well, I prefer more to use basic features than to do some tricks with code - just not my sort of thing. And yes, 3.0.2 does need some options like this one, and to be able to do all the processes with PDF files furthermore. Now, in order to attach, edit and share documents I use a number of tools like this one https://w9.pdffiller.com and it works like charm in my case. But nevertheless, they don't have an opencart plugin for now and I would rather to have all the features from one very place

Newbie

Posts

Joined
Thu May 17, 2018 7:57 pm

Post by OSWorX » Thu May 17, 2018 9:50 pm

nameispalmer wrote:
Thu May 17, 2018 8:09 pm
Well, I prefer more to use basic features than to do some tricks with code - just not my sort of thing. And yes, 3.0.2 does need some options like this one, and to be able to do all the processes with PDF files furthermore. Now, in order to attach, edit and share documents I use a number of tools like this one https://w9.pdffiller.com and it works like charm in my case. But nevertheless, they don't have an opencart plugin for now and I would rather to have all the features from one very place
The offered solution is a very small 'modification' and should do what you need.
Could be also done as Extension.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by mattys » Tue Nov 05, 2019 11:09 pm

Hi

Currently, i am unable to upload PDfs via the filemanager, am using 3.0.2.0.

I have pdfs set up in store settings under system settings, and i have edited admin/controller/common/filemanager.pdf and uploaded, as per post above.

However, i wasn't able to edit admin/view/template/common/filemanager.tpl, as the code is completely different - can anyone advise what the code should be for OC3?

I visted https://www.opencart.com/index.php?rout ... n_id=29701, but not compatible with OC3, and there is one support request, asking for support, but no support offered, so, no go.

i also visted https://www.opencart.com/index.php?rout ... n_id=27763, is not compatible with OC3, and the first support comment is currently 'Can you update this extension for opencart 3.0.2?', it's been there 9 months with no answer, so no go there either.

Am not averse to purchasing a module, it's just my first requirement is that it works and has some support!

There may be a really obvious setting in OC3 that i am not aware of, if anyone knows off...

Thanks

Matt

New member

Posts

Joined
Thu Apr 26, 2012 4:51 pm

Post by IP_CAM » Tue Nov 05, 2019 11:31 pm

admin/controller/common/filemanager.pdf
should rather be:
admin/controller/common/filemanager.php

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by OSWorX » Wed Nov 06, 2019 12:04 am

Alowing to add (and store) pdf (and videos if wanted) is not that culprit - only 2 lines of code (enhance the existing).
So forget all those obstruse extensions.

The major question is more: "how do you want to present them in the shop" and where?
This depends more on the used theme/template and require a few more lines.
And doing such, you have to use the twig syntx: https://twig.symfony.com/
Displayed samples above will not work with OC 3.x because their templates use php

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by mattys » Wed Nov 06, 2019 12:08 am

IP_CAM wrote:
Tue Nov 05, 2019 11:31 pm
admin/controller/common/filemanager.pdf
should rather be:
admin/controller/common/filemanager.php
thanks, but i did realise this, the issue still remains as i need code for 0C3

New member

Posts

Joined
Thu Apr 26, 2012 4:51 pm

Post by mattys » Wed Nov 06, 2019 12:11 am

OSWorX wrote:
Wed Nov 06, 2019 12:04 am
Alowing to add (and store) pdf (and videos if wanted) is not that culprit - only 2 lines of code (enhance the existing).
So forget all those obstruse extensions.

The major question is more: "how do you want to present them in the shop" and where?
This depends more on the used theme/template and require a few more lines.
And doing such, you have to use the twig syntx: https://twig.symfony.com/
Displayed samples above will not work with OC 3.x because their templates use php
Hiya, you sound like you know what you are doing! if you can provide the code please so i can upload PDFs via editor that would be great. As per the first post, it's for filemanager for editor, so, e.g., i would like to add a link to a pdf to category descriptions, so will need to upload the pdf, then link to it.

If i'm honest, i'd rather use a plug in, or a different editor from default than have to learn twig.

I use default theme.

thanks

Matt

New member

Posts

Joined
Thu Apr 26, 2012 4:51 pm

Post by mattys » Wed Nov 06, 2019 1:44 am

Thanks for the responses and suggestions.

I only just realised that this is support forum for OC2! So have moved here viewtopic.php?f=202&t=214663&p=768587#p768587

New member

Posts

Joined
Thu Apr 26, 2012 4:51 pm
Who is online

Users browsing this forum: No registered users and 37 guests