Post by ncc50446@hotmail.com » Fri May 21, 2010 12:17 am

Hey,
i was wondering if there was a way that when you open the image manager, all the folders are automatically expanded? It would also be helpful if it could save the last location of where you selected/uploaded an image from/to. But the auto-expand is the more important feature. I can't seem to figure it out... It would help to speed things up when adding new listings.
Thanks for any help :)
Last edited by i2Paq on Mon Oct 17, 2011 12:23 am, edited 1 time in total.
Reason: Renamed and moved


Posts

Joined
Sat Mar 13, 2010 10:23 am

Post by ncc50446@hotmail.com » Fri May 21, 2010 5:31 am

Well, I found this for it...
http://www.jstree.com/demo/cookie
Just having some troubles implementing it...


Posts

Joined
Sat Mar 13, 2010 10:23 am

Post by ncc50446@hotmail.com » Fri May 21, 2010 11:33 pm

Anyone have any idea's? I see that jstree comes with the cookie plugin, however I can't seem to get it to work by following the instructions. Far from good instructions lol And I don't have a lot of experience with javascript or jquery.
Thank you for any assistance :)


Posts

Joined
Sat Mar 13, 2010 10:23 am

Post by ncc50446@hotmail.com » Wed Jun 09, 2010 2:17 am

Well, I'm still stuck on this problem...
I tried to upgrade to the latest version, 1.0.0 rc, however now it doesn't seem to work with OpenCart, so I'm back to square one.
It can't be that hard to get the jstree cookies to work...However I can't seem to find anywhere on Google on how to do it...
This is something that should be turned on default one would think...
Anyways, has anyone had any success with cookies and jstree?
Thanks


Posts

Joined
Sat Mar 13, 2010 10:23 am

Post by davykeenan » Mon Aug 30, 2010 6:08 am

Did you work this out? looking for solution before i start looking through the files.

Davy K

User avatar
Active Member

Posts

Joined
Tue Jun 16, 2009 8:01 pm

Post by kaylohn » Sat Jan 15, 2011 11:11 pm

Here's something I tried which had worked to some extent:

Im using OC 1.4.9.2 which uses jstree version 0.9.9a

jstree ver 1.0rc2 code will not work

Opened in editor:

admin\view\template\common\filemanager.tpl

Added before the closing head tag:

Code: Select all

<script type="text/javascript" src="view/javascript/jquery/jstree/lib/jquery.cookie.js"></script>
<script type="text/javascript" src="view/javascript/jquery/jstree/plugins/jquery.tree.cookie.js"></script>
Added:

Code: Select all

plugins : {
			cookie : { }
			},
after:

Code: Select all

<script type="text/javascript"><!--

$(document).ready(function () { 
	$('#column_left').tree({
Saved the document.

Tested in FF 3.6 and Chrome 8.0.552 and Opera 11. Works.

The only problem is that it does not open the tree beyond the first node i.e.

Code: Select all

<images>
      <category A>
      <category B>
       .......
Hope someone will help further refine the fix.

Hope this helps.

Lets' forge our present as past for the future. - Kay Lohn


User avatar
New member

Posts

Joined
Sat Jan 08, 2011 12:52 am
Location - Pakistan

Post by kaylohn » Sun Jan 16, 2011 11:01 am

OK. Here goes the fully working (fingers crossed) automatically expanding image manager folder tree to save those precious clicks and have lots of fun using OC.

Here's how:

Im using OC 1.4.9.2 which uses jstree version 0.9.9a

jstree ver 1.0rc2 code will not work

Opened in editor:

admin\view\template\common\filemanager.tpl

Added before the closing head tag:

Code: Select all

<script type="text/javascript" src="view/javascript/jquery/jstree/lib/jquery.cookie.js"></script>
<script type="text/javascript" src="view/javascript/jquery/jstree/plugins/jquery.tree.cookie.js"></script>
Added:

Code: Select all

plugins : {
         cookie : { }
         },
After:

Code: Select all

<script type="text/javascript"><!--
$(document).ready(function () { 
   $('#column_left').tree({
Added:

Code: Select all

var tree = $.tree.focused();
						tree.refresh(tree.selected);
After:

Code: Select all

html += '<a file="' + json[i]['file'] + '"><img src="' + json[i]['thumb'] + '" title="' + json[i]['filename'] + '" /><br />' + name + '</a>';
							}
						}
						
						html += '</div>';
						
						
												
						$('#column_right').html(html);
Added:

Code: Select all

onload: function(TREE_OBJ) {
			
			var myTree= $.tree.focused();
			myTree.open_all('#top');
			myTree.refresh(myTree); 
			}
After:

Code: Select all

$('#column_right').html(html);
						
						var tree = $.tree.focused();
						tree.refresh(tree.selected);
						
					}
				});
			},
Added: (don't forget to copy the comma)

Code: Select all

,
		
		opened: ['top']
After:

Code: Select all

onload: function(TREE_OBJ) {
			
			var myTree= $.tree.focused();
			myTree.open_all('#top');
			myTree.refresh(myTree); 
			}
			

		}
Save the document.

Tested in FF 3.6 and Chrome 8.0.552 and Opera 11. Works like a charm. :)

If you have difficulty entering the code, please download the zip attachment containing the filemanager.tpl file which needs to be copied to admin\view\template\common\ folder inside your OpenCart Installation. Rename your old filemanager.tpl file to filemanager.tpl.OLD incase you want to revert to your previous file.

Hope this helps.

Attachments

The filemanager.tpl file that controls the image manager. Replace yours with this if you have difficulty putting in the code yourself. EDIT: Latest download available at http://www.opencart.com/index.php?route=extension/extension/info&extension_id=3601

Last edited by kaylohn on Sat Nov 12, 2011 6:41 am, edited 1 time in total.

Lets' forge our present as past for the future. - Kay Lohn


User avatar
New member

Posts

Joined
Sat Jan 08, 2011 12:52 am
Location - Pakistan

Post by peacock » Tue Jan 25, 2011 10:55 pm

Love this! Saves a lot of time. Thank you very much. Working perfectly in Version 1.4.9.3

peacock


User avatar
Newbie

Posts

Joined
Thu Jul 23, 2009 9:01 pm

Post by Purebeads » Tue May 10, 2011 3:54 pm

kaylohn, do you think this fix will work in 1.4.8b? I never upgraded to 1.4.9 because of all the customizations I have.

Active Member

Posts

Joined
Fri Apr 30, 2010 12:07 pm

Post by kaylohn » Sun May 22, 2011 6:02 pm

@purebeads, haven't tried it in 1.4.8b, you can try it out and see if it works by making a backup of your original filemanager.tpl and copying the modified filemanager.tpl (see above). If it fails you can easily revert to your original. No harm done. Hope this helps. :)

Lets' forge our present as past for the future. - Kay Lohn


User avatar
New member

Posts

Joined
Sat Jan 08, 2011 12:52 am
Location - Pakistan

Post by Purebeads » Sun May 22, 2011 6:14 pm

Yes, I figured that out. I guess I didn't need to bother you.

It works. Curiously, the subdirectories expand, and then they collapse when the images in the main directory appear, and then they expand again. Even so, it is saving me a click. That extra click is such a nuisance because you have to get your mouse cursor on that very little [+] sign.

To make the file manager load quicker, I am transferring about 2000 images into subdirectories.

By the way, thanks for doing this fix for us.

Active Member

Posts

Joined
Fri Apr 30, 2010 12:07 pm

Post by 321going » Sat May 28, 2011 1:20 am

Good job, thank you very much

Newbie

Posts

Joined
Thu Apr 14, 2011 9:38 pm

Post by webpie it. » Wed Jul 06, 2011 11:49 pm

Works on V 1.5.0.5 and anything below:)

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by lojayatta » Thu Sep 08, 2011 1:22 pm

Thank you so much for this it really helped a lot!!!!

I made the changes and it works fine - I have OpenCart v1.5.1.1 - but my Firefox eror console returns this error

Code: Select all

"Error: a.nodeName is undefined
Source File: http://lojayatta.com.br/admin/view/javascript/jquery/jquery-1.6.1.min.js
Line: 17"
Does anyone know how to fix it?

Appreciated :)

P.S. I attached my edited filemanager.tpl

Attachments

Edited filemanger.tpl for OpenCart


-Sidnei
Image
http://lojayatta.com.br/


User avatar
Newbie

Posts

Joined
Thu Sep 01, 2011 4:19 am
Location - Vitória, ES Brasil

Post by kaylohn » Mon Sep 12, 2011 6:00 pm

Hi!

@lojayatta

I fresh installed OpenCart 1.5.1.1 and used your filemanager.tpl but found no errors. :)

Then I tried the same on a fresh OpenCart 1.5.1.2 install.....still found no errors....

it worked on both versions. :)

Lets' forge our present as past for the future. - Kay Lohn


User avatar
New member

Posts

Joined
Sat Jan 08, 2011 12:52 am
Location - Pakistan

Post by finedesignz » Wed Sep 28, 2011 7:05 am

I have implemented your fix, and it does auto-expand the image folders. But it doesn't remember the folder I just had selected. Did this work for you? Is there any way to make it keep me at the active folder each time I add an image until I change it?

v1.4.9.6

New member

Posts

Joined
Tue Feb 08, 2011 3:57 am

Post by kaylohn » Sun Oct 09, 2011 5:00 pm

Hi Everyone!

After a lot of work and figuring out, I present to the OC community, the properly 'behaving' Image Manager for OC.(this need be packaged in every OC release IMHO)

- Remembers the last opened tree and selected folder.

Tested: OC 1.5.1.3
Browsers: FF 7.0, Chrome 12, Opera 11.51

File attached (ZIPPED) : Extract filemanager.tpl from ZIP and copy to your OC installation admin\view\template\common\ folder. MAKE A BACKUP OF YOUR ORIGINAL in case you want to revert, which I highly doubt ;)

Code below (modified only/partial): for full code view please download and view the source of the filemanager.tpl file.

Code: Select all


...

$(document).ready(function () { 
	$('#column_left').tree({
		plugins : {
			cookie : {}
				},	
		
		data: { 
			type: 'json',
			async: true, 
			opts: { 
				method: 'POST', 
				url: 'index.php?route=common/filemanager/directory&token=<?php echo $token; ?>'
			} 
		},
		
		selected: 'top',
		
		ui: {		
			theme_name: 'classic',
			animation: 400
		},	
		types: { 
			'default': {
				clickable: true,
				creatable: false,
				renameable: false,
				deletable: false,
				draggable: false,
				max_children: -1,
				max_depth: -1,
				valid_children: 'all'
			}
		},
		callback: {
			beforedata: function(NODE, TREE_OBJ) { 
				if (NODE == false) {
					TREE_OBJ.settings.data.opts.static = [ 
						{
							data: 'image',
							attributes: { 
								'id': 'top',
								'directory': ''
							}, 
							state: 'closed'
						}
					];
					
					return { 'directory': '' } 
				} else {
					TREE_OBJ.settings.data.opts.static = false;  
					
					return { 'directory': $(NODE).attr('directory') } 
				};
				
			},	
			

			onselect: function (NODE, TREE_OBJ) {
				
				$.ajax({
					url: 'index.php?route=common/filemanager/files&token=<?php echo $token; ?>',
					type: 'POST',
					data: 'directory=' + encodeURIComponent($(NODE).attr('directory')),
						
					dataType: 'json',
					success: function(json) {
						html = '<div>';
						
						if (json) {
							for (i = 0; i < json.length; i++) {
								
								name = '';
								
								filename = json[i]['filename'];
								
								for (j = 0; j < filename.length; j = j + 15) {
									name += filename.substr(j, 15) + '<br />';
								}
								
								name += json[i]['size'];
								
								html += '<a file="' + json[i]['file'] + '"><img src="' + json[i]['thumb'] + '" title="' + json[i]['filename'] + '" /><br />' + name + '</a>';
							}
						}
						
						html += '</div>';

						$('#column_right').html(html);
						
					}
					
					
				});
				
			},
			
			onopen: function(TREE_OBJ) {
				var tr = $('#column_left li#top li[directory]');
				tr.each(function(index, domEle) {
				dd = $(domEle).attr('directory');
				dd = dd.replace(/\//g, ""); 
				dd = dd.replace(" ", ""); 
				
				$(domEle).attr('id', dd);
				});
				
				var myTree = $.tree.reference('#column_left');
				var cc = $.cookie('selected');
				var bb = '#' + cc;
				myTree.select_branch(bb);
				
			},
			
			
		},
	});	

...

Happy Open Carting!

Please consider donating :)
or
Pass me some work.

++++
Here's an OC demo done by me : itwaarbazaar.com

My deviantArt page: kaylohn.deviantart.com

My YouTube Channel: http://www.youtube.com/kaylohn

+++++++
EDIT
+++++++

Please download from the extensions page for latest version and updates

http://www.opencart.com/index.php?route ... on_id=3601

Attachments

The filemanager.tpl file that controls the image manager. Replace yours with this if you have difficulty putting in the code yourself. EDIT: Latest download available at http://www.opencart.com/index.php?route=extension/extension/info&extension_id=3601

Last edited by kaylohn on Sat Nov 12, 2011 6:40 am, edited 2 times in total.

Lets' forge our present as past for the future. - Kay Lohn


User avatar
New member

Posts

Joined
Sat Jan 08, 2011 12:52 am
Location - Pakistan

Post by lojayatta » Mon Oct 10, 2011 1:38 am

Great job, kaylohn!

Thank you so much!

-Sidnei
Image
http://lojayatta.com.br/


User avatar
Newbie

Posts

Joined
Thu Sep 01, 2011 4:19 am
Location - Vitória, ES Brasil

Post by adriankoooo » Fri Oct 14, 2011 4:03 am

Hi!

Doesn't work for me on 1.4.9.6 :(

When I click on a folder then all folders automatically opens, but why?

Image

Active Member

Posts

Joined
Thu Mar 03, 2011 6:52 am


Post by kaylohn » Sat Oct 15, 2011 4:57 pm

Hello adriankoooo,

Kindly use the file included in the ZIP for this to work on 1.4.x.x

Let me know.

Attachments

Fixed Image Manager for 1.4.x.x EDIT: EDIT: Latest download available at http://www.opencart.com/index.php?route=extension/extension/info&extension_id=3601

Last edited by kaylohn on Sat Nov 12, 2011 6:40 am, edited 1 time in total.

Lets' forge our present as past for the future. - Kay Lohn


User avatar
New member

Posts

Joined
Sat Jan 08, 2011 12:52 am
Location - Pakistan
Who is online

Users browsing this forum: No registered users and 9 guests