JC243 Posted March 9, 2011 Share Posted March 9, 2011 How to read images from 2 or more folders:I have the folders:img/p/a with 1000 filesimg/p/b in 1000 filesimg/p/c with 900 fileslinks.php the file I am modifying the line: public function getImageLink($name, $ids, $type = null) { return ($this->allow == 1) ? (__PS_BASE_URI__.$ids.($type ? '-'.$type : '').'/'.$name.'.jpg') : (_THEME_PROD_DIR_A_.$ids.($type ? '-'.$type : '').'.jpg'); } change: public function getImageLink($name, $ids, $type = null) { return ($this->allow == 1) ? (__PS_BASE_URI__.$ids.($type ? '-'.$type : '').'/'.$name.'.jpg') : (_THEME_PROD_DIR_A_.$ids.($type ? '-'.$type : '').'.jpg'); return ($this->allow == 1) ? (__PS_BASE_URI__.$ids.($type ? '-'.$type : '').'/'.$name.'.jpg') : (_THEME_PROD_DIR_B_.$ids.($type ? '-'.$type : '').'.jpg'); return ($this->allow == 1) ? (__PS_BASE_URI__.$ids.($type ? '-'.$type : '').'/'.$name.'.jpg') : (_THEME_PROD_DIR_C_.$ids.($type ? '-'.$type : '').'.jpg'); } It does not work, I only read the images of the first directory. Missing is any OR or AND, but not how, agradeze your help and there are many waiting for this change because my server does not support more than 1000 files per folder. Link to comment Share on other sites More sharing options...
web.geek Posted March 9, 2011 Share Posted March 9, 2011 I would bet it's the "return" keyword. That usually signals exiting the function at that point, so it may never even check the other folders. Try evaluating the conditions and storing the result in a local variable then only return the local variable. Maybe something like: public function getImageLink($name, $ids, $type = null) { $link = ($this->allow == 1) ? (__PS_BASE_URI__.$ids.($type ? '-'.$type : '').'/'.$name.'.jpg') : (_THEME_PROD_DIR_A_.$ids.($type ? '-'.$type : '').'.jpg'); $link = ($this->allow == 1) ? (__PS_BASE_URI__.$ids.($type ? '-'.$type : '').'/'.$name.'.jpg') : (_THEME_PROD_DIR_B_.$ids.($type ? '-'.$type : '').'.jpg'); $link = ($this->allow == 1) ? (__PS_BASE_URI__.$ids.($type ? '-'.$type : '').'/'.$name.'.jpg') : (_THEME_PROD_DIR_C_.$ids.($type ? '-'.$type : '').'.jpg'); return $link; } This may not work exactly as written, because I don't have any place to test it right now; but it should give you a general idea of the concept. I'm not sure what $this->allow represents. Link to comment Share on other sites More sharing options...
JC243 Posted March 9, 2011 Author Share Posted March 9, 2011 Like the previous code, only reads data located in the last directory "c ".Do not like the expression.Search in the "A", else, look in the "B", else, look in the "C" and so on.Thanks. Link to comment Share on other sites More sharing options...
rojascristian Posted May 22, 2011 Share Posted May 22, 2011 Hello, I have the same problem, my site has more than 14.000 images and my server doesn't allow more than 1000 files per folder. Do you have the anwser to my problem? Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now