Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom Theme PHP File Include Issue
#26
I tried a new path, and moved my projects folder from the theme, to the data/uploads folder

When I do this, I get a 403 Forbidden.

(data/uploads is where I would like to have the projects folder, but was getting issues..so went back to an area where I was comfortable.)

Could there be a case where the file I created does not have the correct read/write permissions?
Reply
#27
No clue what your problem is, works fine for me.

PHP Code:
function my_get_files(){
    GLOBAL 
$TEMPLATE;
    
$folder GSTHEMESPATH $TEMPLATE '/assets/images/';
    
// $folder = GSDATAUPLOADPATH;
    
    
print_r($folder."<br/>");
    
    
$filetype '*.*';
    
$images glob($folder.$filetype); 
    
    
debugLog($images);
    
print_r($images);
}

my_get_files(); 

PHP Code:
C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/
Array ( [
0] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/break.png [1] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/facebook.png [2] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/github.png [3] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/googleplus.png [4] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/icons.txt [5] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/instagram.png [6] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/linkedin.png [7] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/share.png [8] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/tumblr.png [9] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/twitter-alt.png [10] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/twitter.png [11] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/vimeo.png [12] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/youtube.png 

Although I would not use glob if you are not matching patterns or subdirectories.
you can use our $images = getfiles($folder); function if you just need 1 folder or our directoryToArray() function
With glob you are going to have to strip the path off to convert to urls with basename() or something

unfortunately there s no native function to convert file paths to urls, you ahve to do that on your own
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#28
(2015-09-09, 23:12:16)shawn_a Wrote: No clue what your problem is, works fine for me.


PHP Code:
function my_get_files(){
 GLOBAL 
$TEMPLATE;
 
$folder GSTHEMESPATH $TEMPLATE '/assets/images/';
 
// $folder = GSDATAUPLOADPATH;
 
 
print_r($folder."<br/>");
 
 
$filetype '*.*';
 
$images glob($folder.$filetype); 
 
 
debugLog($images);
 
print_r($images);
}

my_get_files(); 

PHP Code:
C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/
Array ( [
0] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/break.png [1] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/facebook.png [2] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/github.png [3] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/googleplus.png [4] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/icons.txt [5] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/instagram.png [6] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/linkedin.png [7] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/share.png [8] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/tumblr.png [9] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/twitter-alt.png [10] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/twitter.png [11] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/vimeo.png [12] => C:\bin\web\dev\getsimple\hotfixes/theme/Innovation/assets/images/youtube.png 

Although I would not use glob if you are not matching patterns or subdirectories.
you can use our $images = getfiles($folder); function if you just need 1 folder or our directoryToArray() function
With glob you are going to have to strip the path off to convert to urls with basename() or something

unfortunately there s no native function to convert file paths to urls, you ahve to do that on your own

As long as I can get the names of each of the files in the directory, then that is all I need. Assembling the URL to append will be simple (The URL creation I have done, just for some reason, it is not finding any files inside the directory).


Could my issue be something to do with a .htaccess file?
Reply
#29
debug your path, its probably wrong.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#30
(2015-09-09, 09:03:12)Tyblitz Wrote: What about doing a scandir on GSTHEMESPATH . $TEMPLATE . '/assets/images/' , then prepend global $SITEURL to each result and output. Voila.

Final solution......


Code:
$folder =  GSDATAUPLOADPATH . 'projects';
$images = array_slice(scandir($folder), 2);
This ended up giving the correct path... and producing results. I guess glob() was not allowed for some reason?
Once I had the file names, I had to create the src url for the <img />


Code:
$path = get_site_url(false) . "data/uploads/projects/";


Then when creating the <img /> I did the following...

Code:
echo "<img class='project' src='" . $path . $i . "' />";


Thank you both for all your help.... It just seems that glob() was not going to work. 
Reply
#31
getfiles() removes . and .. for you
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply




Users browsing this thread: 1 Guest(s)