Jump to content

mallen

Members
  • Posts

    316
  • Joined

  • Last visited

Everything posted by mallen

  1. I am getting closer. <?php echo $Product->ivalue;?> I get this value and all I need is the value of s27 How can I do that: O:8:"stdClass":10:{s:4:"mime";s:10:"image/jpeg";s:4:"size";s:5:"14737";s:7:"storage";s:9:"FSStorage";s:3:"uri";s:27:"cache_276_260__100_A130.jpg";s:8:"filename";s:27:"cache_276_260_100_A130.jpg";s:5:"width";s:3:"258";s:6:"height";s:3:"260";s:3:"alt";s:0:"";s:5:"title";s:0:"";s:8:"settings";a:6:{s:5:"width";i:276;s:6:"height";i:260;s:5:"scale";i:0;s:7:"sharpen";i:100;s:7:"quality";b:0;s:4:"fill";b:0;}
  2. If I echo <?php echo $catt; ?> I get 'wp_mycart_category' so I don't know how it tells that $catt is equal to wp_mycart_category
  3. When I run this <?php echo var_dump($Product); ?> I get the following. Not sure how it includes the categories in the array. I was trying to copy that to get it to include the image. object(stdClass)#561 (12) { ["id"]=> string(2) "51" ["name"]=> string(22) "Nice Shiny Car" ["slug"]=> string(22) "Nice-Shiny-Car" ["featured"]=> string(3) "off" ["variations"]=> string(3) "off" ["categories"]=> string(6) "Luxury" ["mainprice"]=> string( "1.000000" ["maxprice"]=> string( "1.000000" ["minprice"]=> string( "1.000000" ["inventory"]=> string(2) "on" ["stock"]=> string(3) "900" ["catids"]=> string(2) "23" }
  4. I am using this ecommerce theme with Wordpress and now the company is no longer I can't get support. There is a admin page that displays Name, Category, Price, Inventory and ID. I am trying to diplay the product image. If I make any changes to the query I get no reults. If I use Meta::$table I get an error that that Meta does not exits. Is there anywhere else I could check? Maybe the $wpd->wp_mycart_meta line is correct but the query is not. The query pulls data from mycart_price and mycart_catalog but I don't know how it finds those tables. I need to search the mycart_meta $pd = DatabaseObject::tablename(Product::$table); $pt = DatabaseObject::tablename(Price::$table); $catt = DatabaseObject::tablename(Category::$table); $clog = DatabaseObject::tablename(Catalog::$table); $imgg = DatabaseObject::tablename(Meta::$table); // this I added $imgg = $wpd->wp_mycart_meta // I alo tried this $query = "SELECT $columns $matchcol FROM $pt AS pt LEFT JOIN $pd AS pd ON pd.id=pt.product LEFT JOIN $clog AS clog ON pd.id=clog.product LEFT JOIN $catt AS cat ON cat.id=clog.parent AND clog.type='category' WHERE $where GROUP BY pt.id $having ORDER BY pd.id,pt.sortorder LIMIT $start,$per_page"; $Products = $db->query($query,AS_ARRAY); $productcount = $db->query("SELECT FOUND_ROWS() as total"); } else { $columns = "SQL_CALC_FOUND_ROWS pd.id,pd.name,pd.slug,pd.featured,pd.variations,GROUP_CONCAT(DISTINCT cat.name ORDER BY cat.name SEPARATOR ', ') AS categories, IF(pt.options=0,IF(pt.tax='off',pt.price,pt.price+(pt.price*$taxrate)),-1) AS mainprice, IF(MAX(pt.tax)='off',MAX(pt.price),MAX(pt.price+(pt.price*$taxrate))) AS maxprice, IF(MAX(pt.tax)='off',MIN(pt.price),MIN(pt.price+(pt.price*$taxrate))) AS minprice, IF(pt.inventory='on','on','off') AS inventory, ROUND(SUM(pt.stock)/IF(clog.id IS NULL,1,count(DISTINCT clog.id)),0) AS stock"; if ($workflow) $columns = "pd.id"; $query = "SELECT $columns $matchcol FROM $pd AS pd LEFT JOIN $pt AS pt ON pd.id=pt.product AND pt.type != 'N/A' AND pt.context != 'addon' LEFT JOIN $clog AS clog ON pd.id=clog.product LEFT JOIN $catt AS cat ON cat.id=clog.parent AND clog.type='category' WHERE $where GROUP BY pd.id $having ORDER BY pd.name LIMIT $start,$per_page";
  5. I would like to select only the image with 'LARGE' in the name. 1234.jpg 4567_LARGE.jpg 4567_small.jpg
  6. I tried both ways and can't get the syntax correct. $images = glob("$root/$cat/$prod/.{LARGE}", GLOB_BRACE); or this $images = glob("$root/$cat/$prod/.LARGE {.jpg,.jpeg}", GLOB_BRACE);
  7. How can I do a preg_match() to look for images only with "LARGE" in the file name? $prod = isset($_GET['prod']) ? trim($_GET['prod']) : ''; if($prod != ''){ $LARGE = 'LARGE'; preg_match("/$LARGE/", $image); $images = glob("$root/$cat/$prod/*.{.jpg,JPG}", GLOB_BRACE); if(empty($images)){ echo "No large images found."; } else { foreach($images as $image){ //echo basename($image) . '<br/>'; echo 'Large image is'. '<img src="'. $root . '/'. basename($cat) . '/' .basename($prod).'/' .basename($image). '" /><br/>'; } } //var_dump($image); }
  8. Got the images to display with GLOB_BRACE $images = glob("$root/$cat/$prod/*.{jpg,gif,png}", GLOB_BRACE);
  9. Thanks that worked and it was easy to follow. I was able to modify it so it would spread out over individual pages. Now I am try to adapt this to display the images for each product. This is what I have tried but getting NULL for value of images. // if a product is selected, list the images $prod = isset($_GET['prod']) ? trim($_GET['prod']) : ''; if($prod != ''){ $images = glob("$root/$cat/$prod/*.jpg",GLOB_ONLYDIR); if(empty($images)){ echo "No images found."; } else { foreach($images as $image){ $image = basename($image); echo basename($image) . '<br/>'; } } var_dump($image); }
  10. After I get the proper list of folders to display I will work on the display details such as the PDF files and images. On the index page it lists all the categories as links. Category 1 Category 2 Category 3 Then if you click on one it takes you to products_list.php: It lists: Product 1 Product 2 This is the way I want it but its hard coded for category1. I need it to know what category I clicked. This is where I was trying to assigned $curf (current folder)
  11. This is what Ihave so far. I am listing folders and files. Yes I know a database is a better way. My folder structure is products/category1/product1/product2/category2/product1/product2 and so on... On the first page it lists the categories. Then click on them and takes you to a second page to list all products for that category. But all I can do is hard code it for a category. I can't get it to assign a value to $curf //list of functions global $fld; function get_folders ($fld) { //display the main cat folders if ($handle = opendir($fld)) { //open products $blacklist = array('.','..','products', 'index.php'); while (false !== ($file = readdir($handle))) { if (!in_array($file, $blacklist)) { echo '<a href=/products_list.php?folder=' . $file . '&'. 'pdf=' . '/>'. strtoupper($file) . '</a>'. '<br/>'; } } closedir($handle); } } function get_cur_sub () { global $curf; if (!empty ($_GET['folder'])) { $curf = $_GET['folder']; } else { $curf = 'somevalue'; } } function get_sub_folders ($curf) { if ($handle2 = opendir('products/category1' . $curf)) { //need to change hard coded category1 to a variable $blacklist2 = array('.','..','products','index.php'); while (false !== ($sub = readdir($handle2))) { if (!in_array($sub, $blacklist2)) { echo '<a href=/detail_page.php?folder=' . $sub . '&'. 'pdf=' . '/>'. basename(strtoupper($sub)) . '</a>'. '<br/>'; var_dump($sub); } } closedir($handle2); } } //pages: On home page: get_folders ('products'); //get category folder On the products_list.php page: echo get_sub_folders($curf); On the detail_page.php: get_sub_folders ($curf);
  12. I was trying something like this but get a message of bool(false) outside of the function I have : global $file; if ($handle= opendir($GLOBALS['file']))
  13. Is there a way I can use a variable from a function and use it in aother function? function get_folders () { if ($handle = opendir('products')) { $blacklist = array('.','..','products', 'index.php'); while (false !== ($file = readdir($handle))) { if (!in_array($file, $blacklist)) { echo '<a href=/products_list.php?folder=' . $file . '&'. 'pdf=' . '/>'. strtoupper($file) . '</a>'. '<br/>'; } } closedir($handle); } } function get_products() { //if ($handle = opendir('products/category1/product1')) { <<Remove this if ($handle = opendir($file)) { <<try this $blacklist = array('.','..','index.php'); while (false !== ($product = readdir($handle))) { if (!in_array($product, $blacklist)) { echo '<a href=/products_list2.php?folder=' . $product . '&'. 'pdf=' . '/>'. strtoupper($product) . '</a>'. '<br/>'; } } closedir($handle); } }
  14. Ok got it to work. (somewhat) I left off that slash/ on line 6. It now displays the image according to the link I click. Now I need to work on passing the variable for the pdf file. Because all it checks is value of 'folder' function list_directories () { if (!empty ($_GET['folder'])) { $dir = 'products/' . $_GET['folder']; } else { $dir = 'somevalue'; } $images = glob($dir . "/*.jpg"); foreach($images as $image) { echo basename($image); } }
  15. I tried this function and it outputs it if I do a var_dump($dir) but can't get it to echo the values. function list_directories () { if (!empty ($_GET['folder'])) { $dir = 'products/' . $_GET['folder']; } else { $dir = 'somevalue'; } $images= glob($dir . "*.jpg"); foreach($images as $image) { echo $image; } var_dump($dir); }
  16. Can anyone else help? I have been struggling with this for 3 days. The more I look at it not sure (how is currently written) how it knows I want only pdf files to be listed in the second function. My folder struccture is products/category1/product1/product2....category2/product1/product2 and so on. I already can get it to list the category folders as links.
  17. Shouldn't this (glob ($directory, GLOB_ONLYDIR) as $dir) be this? (glob ($directory, GLOB_ONLYDIR) as $pdf) and this echo the list of pdf files?
  18. Not sure where I should put thie part of the code. Should it be on the page where I call the functions? if (!empty ($_GET['folder'])) { $dir = $_GET['folder']; } else { $dir = "default folder"; } $dirList = list_directories ($dir);
  19. Warning: Missing argument 1 for list_directories(), called in /products_list.php on line 16 and defined in functions.php on line 38 Notice: Undefined variable: directory in functions.php on line 43
  20. Is this close? function display_files_pdf () { //display list of pdf files if (!empty($_GET['folder'])) { $dirs = $_GET['folder']; } else { $dirs = 'my folder'; } foreach(glob($dirs, GLOB_ONLYDIR) as $pdf) { echo basename($pdf) . "<br />"; } }
  21. Thanks Christian. I tried what was suggested in post#12 but still no luck. $_GET['folder'] = 'my_desired_folder'; $dirs = $_GET['folder'];
  22. Here are my functions. See I am trying to switch out the$cat variable and also the 'folder' I used the var_dump() and it is showing a value. function get_folders () { //list category folders as list of links if ($handle = opendir('products')) { $blacklist = array('.','..','products', 'index.php'); while (false !== ($file = readdir($handle))) { if (!in_array($file, $blacklist)) { echo '<a href=/products_list.php?folder=' . $file .'>'. strtoupper($file) . '</a>'. '<br/>'; } } closedir($handle); } } function display_files_jpg () { //display list of jpg images $cat = $_GET["folder"]; foreach(glob('products/*/$cat/*.jpg') as $image) { echo basename($image) . "<br />"; } var_dump($cat); } function display_files_pdf () { //display list of pdf files $_GET['folder'] = 'some_value'; $dirs = $_GET["folder"]; foreach(glob($dirs, GLOB_ONLYDIR) as $pdf) { echo basename($pdf) . "<br />"; } var_dump($dirs); }
  23. Ok I put all the function in a separate include file. On index page I have: get_folders (); On the products_list.php?folder= I have display_files_jpg (); display_files_pdf ();
  24. ..localhost/index.php to access the page and it displays the links. I click on them and it takes me to /products_list.php?folder=category2
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.