Jump to content
Latest News: (loading..)

Recommended Posts

Would be difficult to write a HT module (for eg product_listing module) as would not know which products need to be in the HT module [due to how the product_listing module is used].

See what I mean ?


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites
Posted (edited)
4 hours ago, burt said:

Would be difficult to write a HT module (for eg product_listing module) as would not know which products need to be in the HT module [due to how the product_listing module is used].

 

The HT can populate the exact same results.

The listing is an array of data, what even can be used in as a JSON encoded string.

Via javascript it can be added to :
 

$data = json_encode($schema_product);

          $oscTemplate->addBlock('<script type="application/ld+json">' . $data . '</script>', $this->group);

i even think it is not required to send it to the the ht_ inside the header.

imagine the following code for cm_index_new.php :
 

if ($num_new_products > 0) {

	while ($new_products = tep_db_fetch_array($new_products_query)) {
          $OSCOM_Product = new osC_Product($new_products['products_id']);
          $OSCOM_Image = new Image();
          $data[$OSCOM_Product->getID()] = $OSCOM_Product->getData();
          $data[$OSCOM_Product->getID()]['display_price'] = $OSCOM_Product->getPriceFormated(true);
          $data[$OSCOM_Product->getID()]['display_image'] = $OSCOM_Product->getImage();
          $data[$OSCOM_Product->getID()]['display_manufacturer'] = $OSCOM_Product->getManufacturer();
	}
	ob_start();
    include('includes/modules/content/' . $this->group . '/templates/new_products.php');
    $template = ob_get_clean(); 

    $oscTemplate->addContent($template, $this->group);
}

From the provided $data, there could be generated a Schema.via hidden html code.... OR..
A javascript that can wrap the generated code into the <head>...</head> 

The same principe is also for the current code.... this is Class independent.

Edited by wHiTeHaT

Share this post


Link to post
Share on other sites

I understand.  You try it.

 


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites

OP Updated [again].

We may yet get this done for March.


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites

OP updated. Latest update 2.7


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites

OP updated.

Need your view on product_info.php please.

At this moment, the product_info does this;

  1. looks up to see if product ID exists
  2. If no:  displays a message "TEXT_PRODUCT_NOT_FOUND" and button back to index.
  3. If yes:  loads product from database, loads modules, page displays.

For #2, would it be better to have it modularised so that it would be simple to (for example) a module that loads other products from the same category.  


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites
41 minutes ago, burt said:

OP updated.

Need your view on product_info.php please.

At this moment, the product_info does this;

  1. looks up to see if product ID exists
  2. If no:  displays a message "TEXT_PRODUCT_NOT_FOUND" and button back to index.
  3. If yes:  loads product from database, loads modules, page displays.

For #2, would it be better to have it modularised so that it would be simple to (for example) a module that loads other products from the same category.  

Yes. People quite often want extra statuses like 'discontinued' with a different product page and this makes it possible without changing core.

The check query is actually for the product id with status '1' (unlike the query for the breadcrumbs!)


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce here: https://github.com/gburton/osCommerce-234-bootstrap/archive/master.zip

 

For Github users: Bootstrap addons - one per branch - https://github.com/BrockleyJohn/Responsive-osCommerce/wiki/Overview-of-Branches

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites
On 3/14/2018 at 2:36 PM, burt said:

5. getContent calls and Hook calls

  • Discussion needed 

Discuss.


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites
1 hour ago, burt said:

Discuss.

Better to have them and not need them, than to need them and not have them :cool:


If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get the latest community-supported responsive "Edge" release here

Share this post


Link to post
Share on other sites
4 minutes ago, ArtcoInc said:

Better to have them and not need them, than to need them and not have them :cool:

I don't think Gary's one for the scatter-gun approach! Where do you think they are needed?


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce here: https://github.com/gburton/osCommerce-234-bootstrap/archive/master.zip

 

For Github users: Bootstrap addons - one per branch - https://github.com/BrockleyJohn/Responsive-osCommerce/wiki/Overview-of-Branches

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

OK, so far so good. 

I have just updated all the "h" headings to a better size, shopside. This was not a part of the original plan, but the implementation of modular product_info ... it looked good. So also done for the rest of the site.

I have just updated the category_tree class to pull more data and invoked it in /includes/application_top.php

Now any module anywhere, so long as it can global "$current_category_id"...can use the class. This saves on database calls. I've updated index_nested to use the class.  There are probably some header_tag modules that could use it, as well as some other places as well...but that's outside my remit.

Next up is to review @BrockleyJohn index_products.

Thanks.


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites

@burt

Sorry I've been trying to follow along with your work here but am currently buried in Easter orders :)

Regarding the hooks and getContent... I like the idea of having a "global" sort of hook in application_top. That way it can take care of all sort of things (ajax calls, and additions to the switch($action)). When you need to add functionality you just have to create and upload your new hook and done.

I also like the idea of turning the checkout pages into content modules. It would make things a lot easier to alter for people.


Matt

Share this post


Link to post
Share on other sites

Suggestion for hooks:

generic hook registry in each main page or better in application top:

  $OSCOM_Hooks->register(strtok($PHP_SELF, '.'));

Requires namespace convention for first hook level: filename of main page without extension.

Second level: add-on using the hook or hook task:

Example:

// POINTS REWARDS BS
    echo $OSCOM_Hooks->call('checkout_confirmation', 'CheckoutConfirmPoints');

Directory: includes/hooks/shop/checkout_confirmation/points.php

class hook_shop_checkout_confirmation_points {
...
  function listen_CheckoutConfirmPoints() {

 

Share this post


Link to post
Share on other sites

@raiwa

What is the problem with general hooks? Why should it be named
directly? I think if we implement hooks than would be better to call by code part logic instead.
Examples:
- before action
- after action
- before form
- in form
- after form
and so on.

What to do is clear in the hook class but its not clear what name could be applied if we implement non-formal names.


:blink:

Share this post


Link to post
Share on other sites

forum name magic is bugggy @burt @raiwa ... what a magic service

 


:blink:

Share this post


Link to post
Share on other sites

I'm not sure that general hooks serve for all needs of add-ons to call hooks in specific places.

Some files have several actions, some add-ons need to interfere before sql is executed, some after, some need to interfere in e-mail content etc.

 

Anyway maybe first we should define where in a file hooks should be used and where ht or content modules.

My opinion/suggestion:

1. between includes application_top.php and includes template_top.php => hooks

2. in template_top.php header tags are included and most things which can be done in that part and what can be done with the output in header area or footer area should be done with ht.

3. In the content/output part between include template_top.php and include template_bottom.php => content modules => they are more flexible, include config settings, language files, template file for output etc. I wouldn't use hooks in that part.

 

Share this post


Link to post
Share on other sites
Posted (edited)

@raiwa

We could discuss about places but I have to say that pre hard coded addons name using wont be prefered. Call it by functional place is more practic.

For example:

in checkout_confirmation page 'Matc'  is a readable but not pragmatic usage.

  echo $OSCOM_Hooks->call('checkout', 'Matc');


This is a typical 'Form' hook so it would be:

  echo $OSCOM_Hooks->call('checkout', 'Form');

and we could dropp a lot of checkout hooks into catalog/includeshooks/shop/checkout/ directory.

  • formMatch.php
  • formConfirmation.php
  • formChecker.php

Harald implement a general hooks group called 'global' so you dont have to call it in template_top even if it has a special reason.
 

Edited by tgely

:blink:

Share this post


Link to post
Share on other sites
Posted (edited)
22 hours ago, raiwa said:

Second level: add-on using the hook or hook task:

Example:


// POINTS REWARDS BS
    echo $OSCOM_Hooks->call('checkout_confirmation', 'CheckoutConfirmPoints');

Directory: includes/hooks/shop/checkout_confirmation/points.php


class hook_shop_checkout_confirmation_points {
...
  function listen_CheckoutConfirmPoints() {

 

@tgely, it seems there is a misunderstood, if you refer to the above, it was just an example how to apply the namespace.

My suggestion to add to core was only this part:

22 hours ago, raiwa said:

Suggestion for hooks:

generic hook registry in each main page or better in application top:


  $OSCOM_Hooks->register(strtok($PHP_SELF, '.'));

Requires namespace convention for first hook level: filename of main page without extension.

 

Edited by raiwa

Share this post


Link to post
Share on other sites
Posted (edited)

@raiwa

you are right with this general code
 

$OSCOM_Hooks->register(strtok($PHP_SELF, '.'));

and I partly agree with "CheckoutConfirmPoints". This could be pragmatical but very pointed name. This hook states that CheckoutConfirmation function should be there.
 

echo $OSCOM_Hooks->call('checkout_confirmation', 'CheckoutConfirmPoints');

checkout_confirmation explain the path but 'CheckoutConfirmPoints' maybe not referal the real hooked calls. There could be anyting else for example a html canvas, a video or checkbox hook. Its free and wont be predestinated so I suggested the code place name instead.

echo $OSCOM_Hooks->call('checkout_confirmation', 'FormBeforeConfirmationButton');

(Wordpress works by this way).

Edited by tgely
missed Button from context

:blink:

Share this post


Link to post
Share on other sites

I'm not sure if we need the generic hook calls at this point. This could be left to be done by the add-ons installation. A naming convention would be good to be defined.

The generic hook register woul be already a big step maybe together with a already created hook directory structure for the core pages.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×