HTML Catalog Changes

Currently the html catalog only generates the products and categories. It would be nice if it could generate every page, including topics and pages.



Also, it would be great if you could specify the url of each page (including slashes to handle directories and subdirectories). (I know it can be done in SEO module, but I would like to generate static pages).



Thanks.

Hi Storm,



While I hope CS-Cart will make the html generation a priority, it doesn’t appear very likely … at least not soon, especially since the ‘seo’ mod-rewrite functions were put in place. I personally see the mod-rewrite approch as ineffective seo having more disadvantages than advantages. I also prefer a static site, mostly for non-seo reasons. I’ve banged the drum for site-wide html generation many times on here and directly with CS but have mostly thrown my hands up for now because of the lack of positive action. This was one of the PRIMARY reasons I picked CS over other carts, and I was really disappointed to find this isn’t possible and not a priority.



I can’t really go into detail right now on every step, but I’ve come up with a workaround that seems like it will work on my site. It’s still in progress and there are other functions that won’t work and I may ultimately pay to have modified … like search still returns php urls rather than the html version of a page, so it’s far from a perfect solution. But for a basic site I think this approach will generate a complete static html site.



Basically I abandoned the built-in CMS functions, and instead use only the category and product functions. I dug into the code for the update category and update product admin pages and added a few fields that set new variables in my db. Of course I had to add the variables to the db structure in myphpadmin as well.



One of the variables I added was a “page_model” variable, which determines whether the page is a product page (default) or a content page. I then set up my templates to call a different main.tpl file If the page_model is set for content page, which does not display product info (pic, price, add to cart button, etc) and instead only displays the description field which I used to add the content of the page.



I’ve added many such variables on the admin side to control other behavior. One of those is an html_page_name variable that assigns the file name I want for the resulting html file. Same kinda stuff, mostly it’s not that hard to do once you dig into it and see how things are working, but it’s far too complex for me to detail right now. Unfortunately I haven’t managed to handle subcategory creation though I’m sure it would be possible if I knew more php … I’m really only a beginner on that front.



Hope this is helpful. I’m glad to have a compatriot in the campaign to get site-wide html generation completed. Hope one day CS-Cart may accommodate our needs, I’m certain there are more of us than they think.

Thanks for the detailed response!



I have been using a static html for my current cart (not CS-Cart) for 4 years and it has worked out great. Have not had to worry about speed or server issues with a fair amount of traffic. And I’m on a shared host.



I am currently doing my own hacks to try to change all the links on the page. But if I can get proper smarty caching implemented then I would consider using SEO. I have been unable to do so yet. My main problem is having database queries all day long for things that change once a month, if that. I am trying to set this up on a VPS server, so not sure how performance would be once I go live.



I have also created my own custom url field, for products, categories, listmania, pages and topics. And then I am using the new url in the display .tpls. I can try to help you out with your setup if you’d like. I’ve almost got it working but it’s a little messy.

I’m honestly completely convinced that for my size of site / business, static pages are the way to go. Lots of advantages to dynamic sites, but nobody seems to ever consider the drawbacks. My current site (different cart) is static and I have never had any issue with load times, server loads, time-outs, etc. either. 4 years, not a hitch. I just need a better way to manage the site, and a few added functions.



That’s not to say that I’m not using any dynamic functions, just that the majority of the page itself is static.


[quote]My main problem is having database queries all day long for things that change once a month[/quote]

Exactly! CS-Cart, as wonderful as it is, is very query heavy, and I’m not comfortable with that. With my current level of traffic I would increase server loads and my costs significantly by changing to a dynamically generated site, and that simply doesn’t make sense to me. I also have no patience for time-outs and other technical difficulties dynamic sites confront … that’s a customer lost in my opinion.



I appreciate the offer, but I’m really happy with my approach and am getting close. I wish I could get CS to physically save html files to sub-directories of my choosing, but beyond that I think what I’m doing works. Having said that, I feel it’s sad that I would have to jump thru all these hoops to make it work, when html generation for the CMS functions should be relatively easy for the CS-team to implement if they only made it a priority.



Honestly, I wouldn’t use the SEO module if someone held a gun to my head. People are working under the myth that the search engines treat files with .html extensions differently than those with .php extensions. I don’t buy that myth at all, there is plenty of evidence that php sites do just fine in the search engines and the SEO experts I trust deny it makes a lick of difference in your rankings in search results. In other words in my opinion, the SEO mod-rewrite module does absolutely nothing for SEO (If folks think I’m nuts on this issue consider talking to the folks at the highrankings.com forum). My reasons for using a static site are user-oriented, not search results oriented, and using this component just increases server load with no real measurable return.

Great points! I will prob. def. go with static htmls then. I think I will write them to the catalog folder and then rsync it to the actual folders in the root. So I can test as well without needing to push to the live site.



I can try to help you with writing to the subdirectories if you’d like. I am able to do write it to any url I need.



i.e. catalog/trees/green.html



I just defined in my custom url field, /trees/green.html and then made sure I had a trees folder in the catalog folder. Then using html generation, it works fine.

[quote name=‘storm’]

i.e. catalog/trees/green.html



I just defined in my custom url field, /trees/green.html and then made sure I had a trees folder in the catalog folder. Then using html generation, it works fine.[/QUOTE]

Really? Damn, that’s easy … I thought I’d tried that but maybe not. I can see why it would bomb if the directory didn’t already exist. Thanks for cluing me in on that, that will make a huge difference in how I approach things. I noticed your other post about not wanting to deal w/ moving file locations right now and I’m in the same boat. I can’t afford to have any hiccup in the SE’s with my busy season coming up. Could deal with that next fall, but don’t want to wait that long to change over.

yeah, pretty straight forward.



here’s my code in the fn_create _product_page_name in the html_catalog.php. I commented out the original lines and added my own. cstm_page_url being the field with the url name.


//$product_name = fn_generate_name($product, 'p', $product_id);
//return $product_name . $html_ext;
$product_url = db_get_field("SELECT cstm_page_url FROM $db_tables[product_descriptions] WHERE product_id='$product_id' AND lang_code='$descr_sl'");
if (empty($product_url)) {
echo "WARNING: MISSING URL FOR PRODUCT " . $product_id . "
";
}
return $product_url;

Thanks Storm … I’ll compare your changes to mine tonite and see how it goes. This is huge and will save me tons of work in the long run, thanks!

Sure, let me know how it goes. I’ve also got listmania done too, so you can add related products as well, with the static link. Let me know if you’re interested.

Maybe you can explain how you’re using listmania as the way I’m using it it’s just included on the page … I don’t remember needing to make any changes to accomodate html generation or to generate a link. I’d be interested in knowing what changes you needed to make.

Are your listmania links going to your custom url, or the url automatically generated by CS-Cart? If you have not changed it, then likely it is going to the url generated by CS-Cart.



In which case, you may get a duplicate content page penalty if you have the same page via 2 diff. urls.

I understand the duplicate content issue, and in my opinion that’s one of the greatest dangers facing those who have chosen to use the html catalog generation in it’s current form. And it’s a very real danger.



The way I’m currently using listmania though is on the product pages, as an on-page element following the description. I will also be using the tabs but again that’s on-page, isn’t it? I don’t think that changes the url but it’s been a month or more since I played with it.



I’m also using listmania to generate a couple of unique pages for sale items and recommendations, but again those are on-page for pages I have applied my content page trick to.



I guess the exception to this is I’ll be using featured products on the homepage which should link to another page, I just haven’t gotten that far … is this the kind of application you’re using listmania for? Are you using in in a sidebox or similar to link to other pages?

If it stays on the same page you’re fine. I have my Listmania setup to go to a diff. page.



i.e. related items on the product page, or related categories on the category pages.



so, my listmania links go to the custom url. I had to modify the listmania functions file. simple change, let me know if you need it.

I could easily see using those Storm. If you don’t mind sharing, I’d appreciate the info. Thanks.

In /addons/listmania/funcs.php



around line 870, add



global $db_tables; //to allow database for query



and then around line 903, (NOTE THIS IS FOR TOPICS AND PAGES. To do it for products and categories, change the lines around 899. I will change those too, but haven’t gotten to it yet.



it’s mainly the $page_url = …code



You can just modify the pages and topics code for categories and products. Let me know if you have trouble.


} elseif ($object == LM_TOPIC) {
$object_links[$object.'_'.$object_id] = "$index_script?$target_name=topics&topic_id=$object_id";
$page_url = db_get_field("SELECT cstm_page_url FROM $db_tables[topic_descriptions] WHERE topic_id='$object_id'"); //Custom - static htmls
$object_links[$object.'_'.$object_id] = $page_url; //Custom - static htmls
} elseif ($object == LM_PAGE) {
$object_id = fn_get_page_id_by_inner_id($object_id);
$object_links[$object.'_'.$object_id] = "$index_script?$target_name=pages&page_id=$object_id";
$page_url = db_get_field("SELECT cstm_page_url FROM $db_tables[page_descriptions] WHERE page_id='$object_id'"); //Custom - static htmls
$object_links[$object.'_'.$object_id] = $page_url; //Custom - static htmls
echo $dynamic;
} elseif ($object == LM_ADS) {

Tested the saving w/ directory Storm, and it definately works better than my version. They were almost the same except I was going thru an extra and obviously unneeded step using fn_gnerate_name that apparently screwed the poch.



Navigating away from the new page is giving me problems though, as the relative path doesn’t acknowledge the path change. In other words, if I’m at mydomain.com/new_directory/page.html, clicking a home link takes me to mydomain.com/new_directory/index.html rather than taking me back to Web Hosting, Domain Name Registration - MyDomain.com. I’ll have to look at it further, I don’t remember how the navigation is generated.



Big step though, thanks a bunch. Haven’t gotten to part 2 as I don’t have a page set up for listmania to link off page. Hope to test it soon.

Are you talking about the home link in the breadcrumb?

Actually, I was just using “a home link” as an example. I only moved a single product page into the new directory as a test, all other pages were left in the original root directory. All links off the page are including the new directory in their path, so it has to be a relative path issue.

The first code I gave you, changes the file name written. It does not change the links inside the pages. So, I also replaced the url strings in the templates as well. Changing so many, it becomes a mess for sure.



So, on a page where I need to change the product link, I added the code below inside the loop for products in the .tpl



For example, in /skins/customer/products_pages/products_list.tpl



I added:



{if strstr($QUERY_STRING,‘dynamic’)}

{assign var=“final_url” value=“$index_script?$target_name=products&product_id=$products[element].product_id&dynamic=Y”}

{else}

{assign var=“final_url” value=“$products[element].cstm_page_url”}

{/if}



so then, when there is a url call, I change that out with



{$final_url}



to use my static url. If I have appended the field dynamic=Y to the url (so I can test my system in dynamic mode), it keeps the original destination url.



It really is a lot of work to change it this way. I had to change all the template display pages.



The nice thing about my system is that everything is changed all over the site, but many php pages and tpls needed to be changed.



The nice thing about CS-Cart system’s is that they look at the complete page and then change the links. But this is only done on the product & category pages. Not on the complete site.



Maybe if I can use their function to change the page links, but before the page is displayed on the screen.

In thinking about this again, I think i’m going to change my whole way of doing it. I’ve been changing all my templates and php code, but maybe I can simplify it by doing it similarly to what CS-Cart is doing in their html_catalog page. either adding more functionality to that page or modifying the html before it is displayed on the page via Smarty.



Will let you know once I can come up with something.