These are chat archives for reactioncommerce/reaction

2nd
Aug 2016
Spencer Norman
@spencern
Aug 02 2016 00:23
:+1:
Spencer Norman
@spencern
Aug 02 2016 00:56
in defaults.js we’ve got something like this
Session.set("INDEX_OPTIONS", {
  template: "getoutfittedIndex",
  layoutHeader: "goLayoutHeader",
  layoutFooter: "goLayoutFooter",
  notFound: "goNotFound",
  dashboardControls: "dashboardControls",
  adminControlsFooter: "adminControlsFooter"
});
is there a way to replace the default template/workflow for all workflows?
Brent Hoover
@zenweasel
Aug 02 2016 00:56
well, funny you should say that...
Spencer Norman
@spencern
Aug 02 2016 00:57
or other Session globals (PRODUCT_OPTIONS) or the like
Brent Hoover
@zenweasel
Aug 02 2016 00:57
I am creating a method to change the “layout” template for every workflow. Is that what you are talking about?
Spencer Norman
@spencern
Aug 02 2016 00:57
perhaps
we’re trying to get away from our old method of forking core packages/modules
but we’ve also got a layout/theme (whatever you want to call it) that is almost 100% different for all customer facing pages.
Index, ProductDetail, ProductList, Checkout, etc
most of these have their own workflow as far as I can remember.
The new defaults.js has made updating the index pretty trivial
not sure how to do the same type of workflow/layout overriding for the other areas
Is that similar to what your new method will do?
Spencer Norman
@spencern
Aug 02 2016 01:05
separate concern Something in the way the defaults.js style of overriding the index page causes permissions to be invalid for guest users the first time they are loading our index page. Will work on a reproduction
Brent Hoover
@zenweasel
Aug 02 2016 01:06
sorry, we were just finishing up our product meeting
Spencer Norman
@spencern
Aug 02 2016 01:06
no worries, no rush here as I’m about to head for dinner
Brent Hoover
@zenweasel
Aug 02 2016 01:06
do you have different layout templates for different workflows?
Spencer Norman
@spencern
Aug 02 2016 01:07
like different headers and footers?
Brent Hoover
@zenweasel
Aug 02 2016 01:07
no, a separate layout template
Spencer Norman
@spencern
Aug 02 2016 01:07
I think so
our product layout workflow template is different than our index workflow template
but maybe I’ve got an outdated understanding of workflow
Brent Hoover
@zenweasel
Aug 02 2016 01:08
ok, well that’s where the flaw is right now. You can override the layout template with another layout templates (by modifying all the layout records) but you cannot override one particular layout template
I think homepage is a different deal, so excluding the home page
Spencer Norman
@spencern
Aug 02 2016 01:09
I guess what I’m asking is - what’s the best way to modify the layout records without changing core?
Brent Hoover
@zenweasel
Aug 02 2016 01:09
basically my obsession lately is the venn diagram of what you can modify with a template and what people need to customize
Spencer Norman
@spencern
Aug 02 2016 01:10
e.g. we’ve got some product templates (lots really, our whole design) in our getoutfitted-theme module
Brent Hoover
@zenweasel
Aug 02 2016 01:10
Override the template (by setting DEFAULT_LAYOUT), then modify every workflow to use that layout template
you can override each workflow by adding them to register.js
Spencer Norman
@spencern
Aug 02 2016 01:10
ok
last register.js file loaded wins?
Brent Hoover
@zenweasel
Aug 02 2016 01:11
if you want to modify the layout records (e.g. change the templates within them) you will need to do that
Sort of, they both write to Shops.layout
Spencer Norman
@spencern
Aug 02 2016 01:11
we’ve got this:
DEFAULT_LAYOUT = "getoutfittedLayout";
Brent Hoover
@zenweasel
Aug 02 2016 01:12
but if you modify the layout template , it’s going to grab that record
Spencer Norman
@spencern
Aug 02 2016 01:12
productVariant module has this:
  layout: [{
    layout: "coreLayout",
    workflow: "coreProductWorkflow",
    collection: "Products",
    theme: "default",
    enabled: true,
    structure: {
      template: "productDetail",
      layoutHeader: "layoutHeader",
      layoutFooter: "",
      notFound: "productNotFound",
      dashboardHeader: "",
      dashboardControls: "productDetailDashboardControls",
      dashboardHeaderControls: "",
      adminControlsFooter: "adminControlsFooter"
    }
  }]
Brent Hoover
@zenweasel
Aug 02 2016 01:12
yeah, if you look in the sample plugin I modify one of the workflows to use a different template
that function I am adding would just automate changing the template for all the stock workflows
Spencer Norman
@spencern
Aug 02 2016 01:13
how do I change this workflow or whatever to use goProductDetail, goProductNotFound etc
Brent Hoover
@zenweasel
Aug 02 2016 01:13
but even better would just be to have a record for each one, since you may want to change templates as well
the key to grab a layout record is layout (template) + workflow
so if you have a record that is getoutfittedLayout plus “coreProductWorkflow” it’s going to grab that
Spencer Norman
@spencern
Aug 02 2016 01:14
ahh
Brent Hoover
@zenweasel
Aug 02 2016 01:15
I would recommend for you guys that you just have an explicit record for each workflow, because you will want to keep customizing it
        const newLayout = shop.layout.find((x) => selectLayout(x, layout, workflow));
        // oops this layout wasn't found. render notFound
        if (!newLayout) {
          BlazeLayout.render("notFound");
        } else {
          const layoutToRender = Object.assign({}, newLayout.structure, options, unauthorized);
          BlazeLayout.render(layout, layoutToRender);
        }
the issue now is that getoutfittedLayout needs to be generic enough to be used everywhere
You can't use one layout template for coreWorkflow and another for the cart workflow
Spencer Norman
@spencern
Aug 02 2016 01:18
ah
Brent Hoover
@zenweasel
Aug 02 2016 01:18
but once you use your own layout template, it can contain anything
Eventually you should be able to specify a layout template per workflow but not yet
Spencer Norman
@spencern
Aug 02 2016 01:20
just so I fully understand, you’re saying this is no good:
Reaction.registerPackage({
  label: "GetOutfitted Theme",
  name: "getoutfitted-theme",
  icon: "fa fa-television",
  autoEnable: true,
  layout: [{
    layout: "getoutfittedLayout",
    workflow: "coreWorkflow",
    collection: "Products",
    theme: "default",
    enabled: true,
    structure: {
      template: "getoutfittedProducts",
      layoutHeader: "getoutfittedLayoutHeader",
      layoutFooter: "getoutfittedLayoutFooter",
      notFound: "getoutfittedProductNotFound",
      dashboardHeader: "",
      dashboardControls: "dashboardControls",
      dashboardHeaderControls: "",
      adminControlsFooter: "adminControlsFooter"
    }
  },
  {
    layout: "getoutfittedLayout",
    workflow: “coreProductWorkflow",
    theme: "default",
    enabled: true,
    structure: {
      template: "getoutfittedProductDetail",
      layoutHeader: "getoutfittedLayoutHeader",
      layoutFooter: "getoutfittedLayoutFooter",
      notFound: "getoutfittedProductNotFound",
      dashboardHeader: "",
      dashboardControls: "dashboardControls",
      dashboardHeaderControls: "",
      adminControlsFooter: "adminControlsFooter"
    }
  }]
});
Brent Hoover
@zenweasel
Aug 02 2016 01:20
Yep, except you need to make sure and have a record for every workflow
what’s the difference?
Spencer Norman
@spencern
Aug 02 2016 01:22
one is products (list) and other is productDetail (individual product)
Brent Hoover
@zenweasel
Aug 02 2016 01:22
sorry, I didn’t see the remark at the top of the code block at first
Spencer Norman
@spencern
Aug 02 2016 01:22
no worries, I shouldn’t paste this much code at once :/
Brent Hoover
@zenweasel
Aug 02 2016 01:23
Yeah, that’s the idea, but you need to override all workflows, otherwise it will look for getoutfittedLayout + other workflow and won’t find it and get a 404
I am thinking of adding a Meteor.call(“shop/changeLayouts”, “getoutfittedLayout”) type of function to make that easier to people who just want to override the layout template and that’s it
but what you started in that code block is the general idea
Spencer Norman
@spencern
Aug 02 2016 01:41
thanks, this is perfect for us then.
Brent Hoover
@zenweasel
Aug 02 2016 01:42
Great, that makes me happy
3Maestros
@3Maestros
Aug 02 2016 01:52
@ScyDev I believe you have done customization's to host multiple stores (multi-tenant), do you plan to deliver it to github?
Spencer Norman
@spencern
Aug 02 2016 19:58
Getting this error when starting reaction currently: js-bson: Failed to load c++ bson extension, using pure JS version
does that matter?
Spencer Norman
@spencern
Aug 02 2016 20:45
Hey guys @zenweasel or anyone else, still struggling to override these layouts and workflows for our theme
can’t seem to get this template to be overridden
any examples out there of how best to do this would be super helpful
Brent Hoover
@zenweasel
Aug 02 2016 21:35
what’s the problem you are having?
Spencer Norman
@spencern
Aug 02 2016 21:36
none of the layout/workflow blocks that I add to my register are having any effect at all
still loading core layoutHeader and layoutFooter among other things
Brent Hoover
@zenweasel
Aug 02 2016 21:38
you changed the DEFAULT_LAYOUT as well?
Spencer Norman
@spencern
Aug 02 2016 21:38
yes
munireusa
@munireusa
Aug 02 2016 21:38
Where is the best place to find a coder to work on Reaction?
Spencer Norman
@spencern
Aug 02 2016 21:39
only thing that is overriding correctly is the index page
Brent Hoover
@zenweasel
Aug 02 2016 21:40
@spencern Can you put a logging statement here for layout and workflow and see what is happening there: https://github.com/reactioncommerce/reaction/blob/c30ada78d696eec04c3e7c95e8ac238b357443ac/client/modules/router/main.js#L121-L121
@munireusa I would post something on our forums and maybe a note in here: http://discourse.reactioncommerce.com/
If it’s looking for coreLayout then somehow the setting of DEFAULT_LAYOUT is not taking affect
where are you setting that?
Spencer Norman
@spencern
Aug 02 2016 21:42
in a module
and yeah, it’s looking for coreLayout still
even on the home page
Brent Hoover
@zenweasel
Aug 02 2016 21:42
is this code somewhere I can look at it?
Spencer Norman
@spencern
Aug 02 2016 21:43
i can put it up, haven’t comitted in a bit since I started fussing with this
Brent Hoover
@zenweasel
Aug 02 2016 21:43
that would probably be helpful
Spencer Norman
@spencern
Aug 02 2016 21:43
k
Brent Hoover
@zenweasel
Aug 02 2016 21:49
Session.set(“DEFAULT_LAYOUT”, “getoutfittedLayout”)
Spencer Norman
@spencern
Aug 02 2016 21:50
sent you a PM with the repo
Brent Hoover
@zenweasel
Aug 02 2016 21:51
that’s the change you need to make
you can’t reassign a const
Spencer Norman
@spencern
Aug 02 2016 21:52
of course :clap:
damn js compilers not complaining
Brent Hoover
@zenweasel
Aug 02 2016 21:53
got me at first too because you used to be able to do that
oh, because you aren’t importing it
so it’s just “oh local variable, cool"
Spencer Norman
@spencern
Aug 02 2016 21:53
makes sense
working better now, still not loading my header for http://localhost:3000/reaction/product/example-product
Brent Hoover
@zenweasel
Aug 02 2016 21:54
it’s loading the correct layout template?
Spencer Norman
@spencern
Aug 02 2016 21:55
yeah, this might be somethign else
let me dig on this a bit, thanks for the help
Brent Hoover
@zenweasel
Aug 02 2016 21:55
np