• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: CMSMS Shop Skin Helper for osCommerce and Zen Cart + others
PostPosted: Mon Aug 10, 2009 3:07 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Dec 27, 2007 11:29 pm
Posts: 92
Latest Version: 1.2
Download: http://www.studio-owens.com/code/cmsms-shop-skin-helper.htm

About CMSMS Shop Skin Helper:
I've been contacted via email a great deal lately in regards to how I "integrated" CMS Made Simple with osCommerce / Zen Cart. I didn't integrate them, just skinned them.

I skin all the osCommerce / Zen Cart projects with cached skin files, which are generated from a CMS Made Simple page using some predefined HTML comments placed in the template.

I am releasing the basic code I use to do this under the GNU GPL so others can modify and share as desired. The code to generate the skin files is very simple, and every line is commented to make it easy for someone to adapt to their needs. I use variations of this code to create skin files for a variety of PHP apps, not just osCommerce and Zen Cart. I have even used it in conjunction with existing caching systems.

This tool removes that headache of trying to maintain a similarly themed eCommerce package. When a new page is added, or the design changes in CMS Made Simple, the CMSMS Shop Skin Helper does the work of updating the skin files for osCommerce / Zen Cart. The code creates three files from the CMS Made Simple page and uses those files to sandwich the eCommerce pages. This allows the CMS Made Simple menus to be easily updated on a time schedule and/or with a manual call to the CMSMS Shop Skin Helper code.

Manually skinning an osCommerce or Zen Cart installation with a template similar to the CMS Made Simple template is a pain. As multiple template files have to be updated each time something changed with your site's design or a new page is added to the menu. Yuck.

How To Skin osCommerce / Zen Cart:
I provide an example in the download for skinning an osCommerce and Zen Cart installation.

Support:
This thread will be the support page for the CMSMS Shop Skin Helper. Post your questions here and maybe I, or someone else in the community, can help you out.

File Create Functions:
Some servers have disabled allow_url_include for better security. Two create file functions exist: create_file() requires allow_url_include to be turned on; create_file_curl() uses CURL to create the files.

_________________
Studio-Owens.com


Last edited by Anonymous on Fri Nov 13, 2009 3:37 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: CMSMS Shop Skin Helper for osCommerce and Zen Cart
PostPosted: Mon Aug 10, 2009 3:19 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Aug 29, 2007 4:36 am
Posts: 151
Location: Sydney Australia
Very impressive!
I'll test this out on one of my own ideas. If it works out I'll add it to my list of 'offerings'.
I'm getting more and more enquiries about e-commerce.
This looks like a great solution.
Thanks

Simon66

_________________
A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.

This must be Thursday. I never could get the hang of Thursdays.

Douglas Adams - The only sane person in the asylum.


Top
 Profile  
 
 Post subject: Re: CMSMS Shop Skin Helper for osCommerce and Zen Cart + others
PostPosted: Mon Aug 10, 2009 7:54 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Dec 27, 2007 11:29 pm
Posts: 92
Let me know how you end up using it, or if the instructions included in the download need changed.

_________________
Studio-Owens.com


Top
 Profile  
 
 Post subject: Update v1.1: CMSMS Shop Skin Helper
PostPosted: Thu Aug 13, 2009 7:35 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Dec 27, 2007 11:29 pm
Posts: 92
CMSMS Shop Skin Helper - Update v1.1

Some servers have allow_url_include disabled for better security. Starting with PHP 5.2.X allow_url_include is disabled by default. As an alternative method of creating files I have included a second create file function that uses cURL.

If allow_url_include is disabled PHP will throw an error like:
Quote:
Warning: require() [function.require]: URL file-access is disabled in the server configuration in /catalog/cmsms_shop_skin_helper.php on line 100


In this case use the function: create_file_curl()

The the original function requires allow_url_include to be enabled: create_file()

The first post of this thread has the download link.

_________________
Studio-Owens.com


Last edited by Anonymous on Tue Aug 18, 2009 3:04 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: CMSMS Shop Skin Helper for osCommerce and Zen Cart + others
PostPosted: Fri Nov 13, 2009 8:25 am 
I run into a funny result  ???

The website where I am testing the functionality is password-protected (because in state of development, non-public)
Now the 3 generated files contain this content:

Code:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Authorization Required</title>
</head><body>
<h1>Authorization Required</h1>
<p>This server could not verify that you
are authorized to access the document
requested.  Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
</body></html>


What to do? I do not want to disable the auth-directive in the .htaccess ;=)


Top
  
 
 Post subject: Re: CMSMS Shop Skin Helper for osCommerce and Zen Cart + others
PostPosted: Fri Nov 13, 2009 8:35 am 
And I have a second question, which I want to post separately:

How does the script react to changes in the menue (in example new pages are added or deleted), I understand that the script must run to write these into the 3 files

so what do you suggest:

1) run the script using a cron-job

2) include the script in the application (in my case it is a database-related script which outputs some text) and invoke it everytime the script is called?

Thanks in advance, Connie


Top
  
 
 Post subject: Re: CMSMS Shop Skin Helper for osCommerce and Zen Cart + others
PostPosted: Fri Nov 13, 2009 9:12 am 
I used it on a "non-secured" local installation and I am totally impressed! It is exactly what I need!

I ran it manually and was missing some info that the script succeeded.

Would it be too much asked to print some success-message on screen?


Top
  
 
 Post subject: Re: CMSMS Shop Skin Helper for osCommerce and Zen Cart + others
PostPosted: Fri Nov 13, 2009 3:36 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Dec 27, 2007 11:29 pm
Posts: 92
Hello Connie,

Output Messages
I added the $debug variable back into the code. Download v1.2 of the CMSMS Shop Skin Helper from my website, and set the debug variable to true (this is found in the source code around line 56). This will output a success or fail messages to the screen on each step.
http://www.studio-owens.com/code/cmsms-shop-skin-helper.htm



Automatic Script Running
Connie wrote:
How does the script react to changes in the menue (in example new pages are added or deleted), I understand that the script must run to write these into the 3 files


The script doesn't react to changes in the menu, as it is very generic and can be used for any PHP application and not just CMSMS. That being said, you could integrate it into core so each time the menu is updated, the script fires and creates the new skins. However, this change would need to be made each time you updated the code, and it would negate your ability to receive technical support on the core. Therefore, it is easiest to use one of the three following methods to update the menus.


Method One - Setup a Cron Job
Connie wrote:
1) run the script using a cron-job


1) A Cron Job will work fine. Since the Cron Job runs on a set schedule there will be a delay between when the pages are updated and the script fires.

Setting the debug variable to true would be great for running this script as a cron, as it would then send you the success or fail output messages when it runs.


Method Two - Include the File in the Site's Home Page
Connie wrote:
2) include the script in the application (in my case it is a database-related script which outputs some text) and invoke it everytime the script is called?


2) timeToLive
You asked about this on my site, and I personally use this method for some of my clients. The timeToLive variable, and comments on its use, are found directly in the source code.

Open the file: cmsms_shop_skin_helper.php file and look around line 48:
Code:
/* timeToLive can be useed for automated updating of the skin files; not used in the example
install instructions; if you include this file at the top of your eCommerece home page then
timeToLive will cause the skin files to be re-generated every # of seconds; set timeToLive to a low
time if doing many CMSMS template changes; seconds to keep the skin files for;
600 = 10 minutes; 43200 = 12 hours */
$timeToLive = 10;


Set this variable higher to keep the cached skin files longer. The reason to cache the skins is a reduced load time. I had an old method (the old method can be found on my site's blog) that didn't cache the skins from CMSMS and it took way to much time to process.

After you set the timeToLive variable in the source code, include the skin helper file at the top of your site's home page, or in the PHP Application (for example, I typically choose the main page of osCommerce). Your PHP include would look something like this:
Code:
<?php include('cmsms_shop_skin_helper.php'); ?>


Make sure you set the debug variable to false if you are going to use the timeToLive feature. You wouldn't want messages output to the visitor each time the script fires.


Method Three - Manually Call the File
This by far the easiest method. Simply call the file after you make all your page changes. I sometimes create a shortcut in CMSMS for the client to use. http://wiki.cmsmadesimple.org/index.php/User_Handbook/Admin_Panel/Site_Admin/Manage_Shortcuts


Secured Directory
Hum... haven't run into this problem myself. I will ask some of the other developers that are using this script if they have run into this problem.

_________________
Studio-Owens.com


Last edited by Anonymous on Fri Nov 13, 2009 3:39 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: CMSMS Shop Skin Helper for osCommerce and Zen Cart + others
PostPosted: Fri Nov 13, 2009 4:04 pm 
Owen,

it is great. Thank you for your answers and suggestions.

I think I will include into the application script without debug-messages when the inplementation will be set productive ..

I think as I have to integrate some "old" application because it is a relaunch of a 12 year old very active website, I will have need of more than one $cmsmsURL, so maybe I will rename that script or add the $cmsmsURL as variable, would you mind about that?

Thanks again, this is a great tool!

Connie


Top
  
 
 Post subject: Re: CMSMS Shop Skin Helper for osCommerce and Zen Cart + others
PostPosted: Fri Nov 13, 2009 4:31 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Dec 27, 2007 11:29 pm
Posts: 92
Connie wrote:
I will have need of more than one $cmsmsURL, so maybe I will rename that script or add the $cmsmsURL as variable, would you mind about that?


You can do what you want with it as long as you keep the copyright and GNU GPL license intact. More details here: http://www.studio-owens.com/code.htm

This code is distributed under the GNU General Public License, which is a Free Software license. It grants to you the four following freedoms: (1) The freedom to run the program for any purpose; (2) The freedom to study how the program works and adapt it to your needs; (3) The freedom to redistribute copies so you can help your neighbor; (4) The freedom to improve the program and release your improvements to the public, so that the whole community benefits.

_________________
Studio-Owens.com


Top
 Profile  
 
 Post subject: Re: CMSMS Shop Skin Helper for ZenCart from Carol
PostPosted: Sun Feb 13, 2011 8:19 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Dec 27, 2007 11:29 pm
Posts: 92
Carol wrote:
Hi Stephen, I've gone thru the about.pdf and followed the instructions for zencart. My installation for cmsms and zencart are vanilla other than shop being in a different folder. The cmsms_shop_skin_helper.php ran and created 3 files in the shopskin folder. But I have no skin for cmsms or zencart. Any ideas where I should look next? I've double checked every instruction to make sure I didn't miss anything. Thanks. Carol


Not sure exactly what you mean by "I have no skin for cmsms or zencart" so my best guess is that
(a) the CMSMS page (that is set in STEP 3 of the About.pdf) is not using the modified template (created in STEP 2 of the About.pdf);
(b) your ZenCart template isn't setup properly to use the skin files created by this code (as described in STEP 4 on page 5 of the About.pdf).

If I were you I would go back to the beginning of the About.pdf and follow the directions again. Or you can hire me to set up the Shop Skin Helper for you. If you are interested in my professional web development services, just send me a message.

In order to provide more assistance via this thread I will need some more information from you:
1. The URL for the page you are using in "STEP 3: Modify the settings in cmsms_shop_skin_helper.php for your site." part 1.
2. The source code for the CMSMS template that you are using.
3. The source code for the ZenCart template you are using.
4. URL to the directory with the 3 skin files that are being created by the Shop Skin Helper.


Top
 Profile  
 
 Post subject: Re: CMSMS Shop Skin Helper for osCommerce and Zen Cart + oth
PostPosted: Wed Apr 13, 2011 1:10 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Fri Apr 18, 2008 9:34 pm
Posts: 115
Location: Nimbin, Australia
Hi there
I installed the skin maker in combination with os commerce and all is good.
only the navigation that points from cmsms at os commerce pages:

/catalog/somelink.php

are rendered to
/catalog/catalog/somelink.php

an absolute link fixes that problem
http://myURL.com/catalog/somelink.php

however, that makes the site less portable.
does anyone know a way to include {smary} in the url field in content->pages?
or is there another way? a redirect or something?

cheers, mario


cheers


Top
 Profile  
 
 Post subject: Re: CMSMS Shop Skin Helper for osCommerce and Zen Cart + oth
PostPosted: Wed Apr 13, 2011 3:13 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Dec 27, 2007 11:29 pm
Posts: 92
rotezecke wrote:
...

only the navigation that points from cmsms at os commerce pages:

/catalog/somelink.php

are rendered to
/catalog/catalog/somelink.php

...


Mario,
Attached is a relative URL fix. I didn't upload this file as an official release to my website yet, as it is untested. So let me know if this works for you. However it should work fine.

I added a function that performs a RegEx and removes catalog/ from href links.

If you need something different let me know. I code for money.


Attachments:
File comment: Does not contain the entire package. Only contains a modified version of cmsms_shop_skin_helper.php
relative_url_fix_untested.zip [2.88 KiB]
Downloaded 112 times
Top
 Profile  
 
 Post subject: Re: CMSMS Shop Skin Helper for osCommerce and Zen Cart + oth
PostPosted: Fri Apr 15, 2011 4:11 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Fri Apr 18, 2008 9:34 pm
Posts: 115
Location: Nimbin, Australia
Thanks. the fix didn't quite work as is.
was:
Code:
function relative_href_fix($string, $debug) {
  $dirRemove = 'catalog';
  $pattern = '/(href)\s*=\s*"('.$catalog.'\/)([^:"]*)(?:")/is';
  $replace = 'href="$3"';
  $string = preg_replace($pattern, $replace, $string);
  if ($debug == true) echo '<p>File Modified with relative href fix: <strong>'.$fileName.'</strong></p>';
  return $string;
}

is now:
Code:
function relative_href_fix($string, $debug) {
  $dirRemove = 'catalog';
  $pattern = '/(href)\s*=\s*"('.$dirRemove.'\/)/';
  $replace = 'href="';
  $string = preg_replace($pattern, $replace, $string);
  if ($debug == true) echo '<p>File Modified with relative href fix: <strong>'.$fileName.'</strong></p>';
  return $string;
}


this part:
([^:"]*)(?:")/is
regular expressions give me a headache; all i know it didnt work. hence the simplified version.

oh, and the line where the function is called needs a semi-colon.

thanks again.


Top
 Profile  
 
 Post subject: Re: CMSMS Shop Skin Helper for osCommerce and Zen Cart + oth
PostPosted: Wed Apr 20, 2011 9:09 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Dec 27, 2007 11:29 pm
Posts: 92
Glad it was helpful. Yep the pattern had $catalog instead of $dirRemove, and should have been:
Code:
$pattern = '/(href)\s*=\s*"('.$dirRemove.'\/)([^:"]*)(?:")/is';

rotezecke wrote:
this part:
([^:"]*)(?:")/is
regular expressions give me a headache

I'll try to break it down... knowledge is power.

The Regex parts found in the above statement
[ ]
matches any single character within the brackets; so [a-z] would match alpha lowercase character

[^ ]
the caret here means to match any single character that is NOT within the brackets; example [^0-9] would match any character that is NOT a number

*
repeats the previous item zero or more times

( )
create a capturing group; backreferences allow you to reuse this part of the regex match

(?: )
create passive group; the question mark and the colon after the opening round bracket mean this group is NOT captured for backreference

So the three things found in the Regex you have questions about are:
([^:"]*)
Here I was looking for anything that could be found within the double quotes of a href. I am matching anything that is NOT : (colon) or " (quotation mark) as a quotation mark would denote the end of the href=" " attribute.

(?:")
This is matching the closing quotation mark, but I didn't need a backreference for my purpose.

/is
The closing forward slash. The /i makes the regex case insensitive. The /s enables single-line mode, to handle the href if it was split across multiple lines for whatever reason.

A sample PHP script to help illustrate the above matches and resulting replacement...
Code:
<?php
$dirRemove = 'catalog';
$string = '<p>Here comes a catalog/ directory link <a href="catalog/mypage.php">catalog/mypage.php</a> to be fixed.</p>';
$pattern = '/(href)\s*=\s*"('.$dirRemove.'\/)([^:"]*)(?:")/i';
$replace = 'href="$3"';

echo '<p>HTML BEFORE:</p><p style="color:red;">'.htmlspecialchars($string).'</p>';
echo '<hr/>';

echo '<p>REGEX MATCHES:</p>';
preg_match($pattern, $string, $matches);
echo '<p style="color:red;">';
print_r($matches);
echo '</p>';
echo '<hr/>';

$string = preg_replace($pattern, $replace, $string);

echo '<p>HTML AFTER:</p><p style="color:red;">'.htmlspecialchars($string).'</p>';
echo '<hr/>';
?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
A2 Hosting