Misunderstanding Front Matter? - bigcommerce

Still a newbie at BigCommerce, and I'm wondering if I'm not quite getting the use of Front Matter YAML in my templates. I'm using the Stencil CLI and trying out changes to the front matter of my main product.html template, and I'm observing the results of a request to a product page with the ?debug=context querystring. I'm using https://developer.bigcommerce.com/stencil-docs/ZG9jOjIyMDcxNg-front-matter-reference for reference.
I'm not clear on when "Global Attributes" are populated without requiring Front Matter. For example, "categories" is populated in the debug info, even though "categories" isn't explicitly included in the Front Matter of product.html. But on the other hand, "blog" is empty in the debug info until I add a "blog" entry with "recent_posts" in the Front Matter. Then it's populated. What's the difference between the two?
Can data that's not in "Global Attributes" not be added to pages of other types? For example, what if I did want the full content of blog posts available on the product page? Can I not add a "blog" entry with "posts" (not "recent_posts") to the Front Matter because it's not a blog page? (Attempting to do so just results in empty data for "blog" in the debug info.)

Related

Razor Page with dynamic form

Having recently migrated from years of web forms, I’ve built numerous dot net core razor page apps - So I’m not a complete beginner but I am struggling to understand the best way to approach one particular scenario. I have a page that captures some header information but also needs to capture some additional data that is specific to the “type” of record being edited. In webforms I dynamically loaded a user control for the relevant type using a path name (the path name of the user control being linked to the type so the system knew what form to load). With user controls I could then handle the form submission which meant the logic could be completely different for each type/form. Whereas I can use view components to create the relevant UI in the same way in my razor pages app, I can’t then handle the post back from there. So what would be the best way to approach this in razor pages? To make matters more complex, the type (and thus the objet i want to capture) could be defined in a RCL (another project). Also the type needs to be defined in a database entry, so I need to be able to load it from a string. Whereas a standalone page for each type would be easy, the management of this data is on one place in the core system so I can’t have a different page for each one.

URL Query Parameter

I am a novice to APIs and I am aware of the major kind of path in a rest API: path such as www.example.com/carsand query parameters such as www.example.com/cars?color=blue.
I just visit an e-commerce website and I am confused about the current path. I selected the category iphone-8 and got that url: https://www.example.fr/iphone-8.html
On the same page, I filter all phones with a price between 250 and 300 euros. This is the new url: https://www.example.fr/iphone-8.html#price=250&price=300
Does this url means that the filter is only applied on the html because of the # and therefore there is no api call for filtering?
Does this url means that the filter is only applied on the html because of the # and therefore there is no api call for filtering?
No that doesn't follow.
The experiment to try would be to load the original page into your browser, turn on the developer tools used to watch the network traffic, and then perform your search.
What you may discover is that when you manipulate the filter controls on the web page, what's really happening under the covers is that java script code is running, and making calls to fetch data from some back end endpoint, and then re-rendering the web page on the client. The fragment is being updated so that, if you were to bookmark the link, or copy it to another tab in your browser, the underlying javascript can reproduce "the same" results (by getting the search parameters from the fragment and repeating the search).
It should be possible to repeat those same calls directly from the browser itself (you won't necessarily get the HTML rendering, of course, but you'll probably be able to look at the filtered results in their own native representation (application/json, perhaps).
What's the avantage of using the frag rather than the query parameters for price?
Fragments are not part of the absolute-URI, and the query part is.
Which is to say, the query part is still part of the identifier of a primary resource, and is part of the request-line that is sent to the server.
But fragments are used to identify secondary resources; resources embedded within some primary resource.
Consider:
https://www.rfc-editor.org/rfc/rfc3986#section-3.5
This identifies a secondary resource (specifically, section-3.5) that is included within a primary resource (an HTML representation of RFC 3986). So we "fetch" the secondary resource by first loading the primary resource (the whole RFC) and then use the fragment identifier and HTML processing rules to discover the appropriate element in the document.
The fragment part is strictly a client side concern.

2sxc Blog App - Where Are Module Settings Stored?

In the Blog App (I am using 3.00.02 I think), I notice the queries for the main article list have filters for In:Settings:Category. This appears to be Module Settings, but I am not sure. Can you tell me how/where to add and store these settings? I am hoping they are module settings of some kind so I can filter for different types of articles (press vs news vs announcements) on different pages across the site.
Is there an example somewhere in the app of how this filter is used?
Anything on the "In" comes from an in-stream on that data-source. So that block must have an inbound stream called "Settings" - look at where that comes from.

Use category name in Sitefinity blog URL

I followed the instructions here on establishing a new provider and generating custom URLs, and it works as expected. There doesn't seem to be a clear reference for what parameters can be utilized in the settings as the example given is very basic.
I want to use the category name of the post in the URL. I tried:
/[Category]/[UrlName]
but what I got in the frontend was:
http://localhost:60327/my-page/Telerik.OpenAccess.TrackedList%601[System.Guid]/my-post-name
I also tried
/[Category.Title]/[UrlName]
which just threw errors.
Anyone know how to do this, or better yet, a good reference for the parameters?
I don't think this is possible since the Category property is actually a collection (TrackedList).
In theory you would need one of the collection items, let's say the first one, and your URL expression would be /[Category[0].Title]/[UrlName], but this is currently not supported by the expression parser.
Also, the idea of making the URL dependent on a complex (related) field is not a good idea. If someone deletes that category, they will break all your blog post URLs.
I would suggest you to create a custom text field for the blog post item (ex: CategoryUrl) and then you should be able to set the URL format to /[CategoryUrl]/[UrlName]. Make sure CategoryUrl field is required.

JSON LD + Schema.org - only on homepage or on all pages? [duplicate]

Should the "WebSite" and "Organization" types and their properties be applied to all pages of a website or just the homepage?
I have valid JSON-LD code defining the the necessary items for Google mobile search results, but I am not sure if it should be included on all pages or just the root/home page.
It would make sense to provide it on any page where it’s relevant.
For example, if this is an organization’s website, each page is about/from the organization, so provide metadata about this organization on each of the pages.
A consumer looking for structured data on a certain page is not necessarily also visiting and checking the homepage, so it might never learn that you are providing relevant metadata.
That does not necessarily mean that you should include the full item (with all properties) on each page. It can be sufficient to provide the full item only on one page (e.g., on the site’s homepage), and link to it (for example with the property author) from each other page.