Change media image folder name

Gast

 (Y) (Y) (Y)

Thanks!!

i'll do the same over the weekend

sky writer

Hi Jacobi,

I used Christoph's fix, because it works as is.  And since future upgrades will require a new search and replace with either approach, maybe this is the most sensible solution.  At least until the future possibility of something similar being implemented into the bakery core.

But I didn't given up on your idea, because I think it would be a helpful addition.

Here's what I did to get it working.

added your code to the bottom of the bakery/config.php file:
// name of the bakery image folder in media
$sBakeryImgFolder = 'products';  //no leading/trailing slash or backslash!! A simple directory name only!! 


Renamed my media/bakery folder to media/products

Did a search (Find in Files) with Notepad++ for all instances of (31 total in 8 files):
MEDIA_DIRECTORY.'/bakery
and replaced with:
MEDIA_DIRECTORY.'/'.$sBakeryImgFolder.'

There are two files which require different replace formatting
'save_item.php' ~line 278
MEDIA_DIRECTORY.'/'.$sBakeryImgFolder.
notice the difference, there is no single quote between MEDIA_DIRECTORY.'/'.$sBakeryImgFolder.   <and>   $directory;

uninstall.php ~line 52
MEDIA_DIRECTORY.'/'.$sBakeryImgFolder
notice the difference, there is no trailing single quote or concatenation.

I took a look at the OneForAll module files and the calls are to the info.php for the module name '$mod_name' - to complete the media folder path.

There are two files which aren't displaying the images in bakery with the above settings in place, modify.php and view_overview.php

I added the following to those two files (near the top, although I do not know if placement matters), and it now everything seems to work:
// Get some default values
require_once(WB_PATH.'/modules/bakery/config.php');


But I do not know enough to know if this is all something that should be done, or what effect it might have.  But it was fun working it out.

Gast

Quote from: sky writer on October 15, 2015, 06:50:23 PM
I took off your trailing forwardslash, because that caused the search and replace to miss some files.

i test only some pages in the backend, but not all functions.  :oops:
Do you have a working solution on this basis now?

P.S.: i think, a good example must be be OneForAll-Module (if i remember correct, it have a way like this in the code)

sky writer

Jacobi,

I tried your idea, because I like the thought of being able to change this folder more easily.  But the variable doesn't load in the admin (modify.php) or on the main products overview frontend page (maybe elsewhere, but I noticed these two for sure).

I took off your trailing forwardslash, because that caused the search and replace to miss some files.

replace:
MEDIA_DIRECTORY.'/bakery

with:
MEDIA_DIRECTORY.'/'.$sBakeryImgFolder.'

Gast

is it not a better solution, if you define the gallery folder name in the file modules/bakery/config.php maybe with

<?php for colored code onlydont copy that line
// name of the bakery picture folder in media
$sBakeryImgFolder 'products';  //no leading/trailing slash or backslash!! A simple directory name only!!  
                       

and change

MEDIA_DIRECTORY.'/bakery/

to

MEDIA_DIRECTORY.'/'.$sBakeryImgFolder.'/

??


freeSbee

Hi sky writer

You can use your favorite IDE to perform a search / replace on all Bakery files. The path is hard coded about 33 times. Search ...
MEDIA_DIRECTORY.'/bakery

and replace by ...
MEDIA_DIRECTORY.'/products

The main drawback of changing hard coded directory names is that you will have to redo it each time you upgrade.

Regards Christoph

sky writer

How difficult is it to change the media/bakery image folder to something else, like media/products?