how do breadcrumbs work? - yesod

beyond the trivial
instance YesodBreadcrumbs MySite where
breadcrumb RootR = return ("home", Nothing)
breadcrumb FirstPageR = return ("first page", Just RootR)
breadcrumb SecondPageR = return ("second page", Just FirstPageR)
does anyone know how to implement breadcrumbs for situations where a specific page can be reached from several different parents for example?
thanks
konstantin

Apologies as this isn't a technical answer but more of a UX answer...
where a specific page can be reached from several different parents for example
If that's the case, then your site's IA isn't conducive to breadcrumb navigation. Showing the same page with two different sets of breadcrumbs will only confuse users. I'd suggest that you instead reference the content in one section of the site from the other rather than duplicate it.

Related

Is it possible to make 'cart' with django Class Based View?

I am trying to make a simple e-commerce website and followed some tutorials.
However, the author of the book used complicated function based view to make cart function..
there are bunch of session stuffs.. and I don't understand the logic..
and I am trying to think the other way..
what about using database to store all the cart related data, and
use CBV to build it?
for example,
CartListView to see the contents of the cart, and CartUpdateView to change the quantity..
then are they going to be two different pages? separated page that user should go to the
different page to change the value??
please help me T T
You can access the session in any sort of CBV as self.request.session and a "shopping cart" is normally stored therein.
You'll certainly need to implement a CartListView to see what's in it, or possibly a CartEditView to show the cart with options to edit the quantities and delete anything that shouldn't be in there.
Adding products to the cart may well be an "Add" button on a ProductDetailView or lots of add buttons in a ProductListView. You might add a POST handler method to these views which are otherwise read-only (GET-only) bt default. Or you might make them FormViews, even though the form would be hidden and filled/POSTed by JS rather than the shopper doing anything other than clicking "add".
And then there will be a CheckoutView.
Check https://djangopackages.org/ (put "cart" in the search box). this will throw up several shopping cart things which might be the code you want, or the source of which might be a valuable learning resource before you end up rolling your own.

Oracle APEX - Breadcrumb entry with multiple parents

I am working on this app where many pages (8+) are linking to the same page. Every page needs to show correct breadcrumb. Since many pages are linking to the same page, the target page (p5) has a number of breadcrumbs and each breadcrumb has a condition that an application item needs to have a specific value for the parent page.
For example pages 1,2,3,4,6,7 link to page 5. So page 5 has 6 separate breadcrumbs on it where the condition is when parent_page = x where x is the parent page number. So if the user comes from page 1, a correct breadcrumb is selected.
I feel that this is excessive and creates a mess. Also the number of pages that link to page 5 seems to grow. I could create new breadcrumbs for each parent page but I feel that this is wrong and want to find a better way. Can anyone point me in the right direction? how have you handled something like this in the past?
I haven't actually done it, but I remember wanting to at one time. I think you would need to "roll your own" breadcrumbs. You could use an APEX collection to keep track of the user's navigation by "pushing" and "popping" pages on to and off of the APEX collection. Then create a SQL-based list region to display these. You may need to create a bespoke list template to make this list look like breadcrumbs.
Had a similar requirement. Many paths to a single location and keeping the breadcrumbs in sync with the users path was a coding horror story. Finally we decided on not going down that road. The breadcrumb now shows the main path back to the main screen, which might not be the exact path the user followed. So, just a single breadcrumb per page. If you want to go back to the previous page then a "back" or "cancel" button could still do that, but not the breadcrumb.

Joomla Proper CMS for complex design

i am very confused right now. I came from Wordpress,and laravel frameworks, and now i am assigned to develop Joomla! project.I thought i can easily manage to create custom template in joomla. I have been reading a lot of articles and documentation. I've manage to create a template and display modules.
But now, i need to start digging the right way to display the content and manage it in Joomla! back-end.
Here's my problem. I have home page (Long page) and inner pages (Short page). Here's the structure of my homepage
<html>
... header links and other necessary tags
<body>
<section class="homepageonlysection1">
<div>
image and text here! (i made this as 1 modules in Custom HTML)
</div>
<div>
video here (i made this as 1 modules in Custom HTML)
</div>
</section >
<section class="homepageonlysection2">
<div>
form here (i made this as 1 modules in Custom HTML)
</div>
<div>
image and text here! (i made this as 1 modules in Custom HTML)
</div>
</section>
<section class="homepageonlysection3">
<div>
image and text here! (i made this as 1 modules in Custom HTML)
</div>
<div>
video here (i made this as 1 modules in Custom HTML)
</div>
</section>
</body>
</html>
and this is my inner pages
<html>
... header links and other necessary tags
<body>
<section class="innerpagessectiononly1">
<div>
Article Content (i will do as jdoc:inlucde type="component")
</div>
</section>
<section class="innerpagessectiononly2">
<div>
sidebar Content (i will do this as 1 modules in Custom HTML)
</div>
</section>
</body>
</html>
Those template are really different.
Problem 1 : How can i make my inner pages if my homepage structure is very different? Or
Problem 2 :How can i make display my section (homepageonlysection) in home page only and display (innerpagessectiononly) in inner pages only?
Problem 3 : Is there a Advance Custom Field (ACF for wordpress) as joomla extension ?
Please advice. Any help would be appreciated.
One thing I recommend is really digging into the core templates (both front and backend) to understand how things work. In particular Isis the backend template illustrates a number of complex options.
Now, overall I think you probably do not want to do the homepage the way you are doing it, since it will be very inflexible and hard to change. On the other hand it's possible that you want it inflexible and hard to change. In reality you may not need to have separate layouts at all or the differences may be minimal and may not require any special code at all.
So, first, this document explains how to determine if you are on the home page. So you can clearly pretty easily test for that and then enclose your two separate designs in the true and false conditions. This is basically what you see in Isis. In your case you can place one or more module position inside the condition. In fact you could make it so this layout does not even load a component. Then you can just make an empty article and make the home page a single article link to that empty article. (I would put that article into a separate landing page category)
A second option if you really want to have a totally different design on the home page is to make a totally separate template for the home page. If say you called this "my home template" and your other template "my everywhere else template" what you could do is make "my everywhere else template" the default and then on the default (homepage) menu item assign the "my home template" template. In this special template you can even use the module jdoc:include (instead of modules) to call specific modules in highly customized ways. I would suggest you go read the docs on that. You can even set the options and the chrome right in the template.
However, I think you are missing a key feature of Joomla. In your question you have not said what kind of menu link you are planning to use for your home page. The third option is that for the homepage you use the same template but a specific alternate layout that you use for this page. For your case what you would most likely want to do, assuming that you are not using the featured articles layout type anywhere else (i.e. that no articles are marked featured), is to make your homepage using an articles > featured menu link. Then you can assign all the modules you made to the home page via the menu modules tab. Depending on how your module positions are in the template it could just be that they will float up.
Your design is not a particularly unusual or complex however. Many Joomla homepages consist of multiple structured sections of text and media. These are made with menu types such as "featured" and "category blog." The advantage of using these menu types is that then you are storing your content in articles and these are much easier to manage. ALso you don't have to give someone access to the module manager in order to allow them to edit these snippets of content. So the fourth and possibly best approach is to use one of these standard content layouts. For example if you were to make a category called "home page content" and then put the content for each of the modules in a separate article and (assuming you want a consistent structure) put the image for each of them into the structured intro text image field, you can then make a "category blog" menu link to the "home page content" category as you default (home page) menu link. Then what you can do is make one or more layout override for those individual items that gives the exact layout you want. Assuming that they are all the same, you can select that as a alternate layout in your menu link. Actually even if they are not all the same you can just do a more complex layout instead of looping through the list and doing the same thing for each article, do each one separately.
A fifth approach is to use an alternative layout instead of an alternate layout. The difference there is that you would give the layout a new name (in either the category or featured view) and then you will have the additional flexibility of being able to create options in the menu link that are different than those for the normal category/featured views. It's up to you to decide what you might want to add there.
There are other options as well, because Joomla has a very strong template community and they like to have a lot of flexibility. But that will get you started.

Bigcommerce Templates file missing

I am developing a template for bigcommerce site, where i want to show category list and some hard code links in the place of Page menu. Now what i do, just place this %%Panel.SideCategoryList%% in the upper navigation area. Which shows category list right.
But the problem is that i didn't find this %%SNIPPET_SideCategoryList%% file. (In snippets folder exist a file with this name, but that file doesn't work even if i remove all contents of that file.)
I had a similar issue with SNIPPET_SideShopByBrandList.
I logged a ticket and got the following response:
Thank you for contacting BigCommerce technical support.
I see its reference in SideShopByBrand panel. In the same panel, there is another SNIPPET_ShopByBrandAllItem which is visible in snippets tree, but not this one. That's because its a hidden snippet, and its not possible to edit this.
I have tested this in my personal store as well, and the output is same. let me know if you have any other questions.
I think yours might also be a "hidden snippet and not possible to edit"
No worry....You need to just create html page and put the below code but keep one thing don't include the html, head, body etc
1) just create a html page and delete the html content
2) put the below my code for
3)
<li class="%%GLOBAL_LastChildClass%%">%%GLOBAL_CategoryName%%
%%GLOBAL_SubCategoryList%%
</li>

Can I use something like Hyde from within Django?

I have a site with a few hundred pages where maybe 75% of pages are static content and the rest fit the typical "web application" model. My preference is Django, so I've mostly been looking at solutions based on that.
The content is very bespoke -- most pages share little beyond the basic site chrome, and are complex enough that it's simpler to write them in HTML rather than try to wrangle a rich text editor into giving the correct output. So the direction I'm currently going is to just define the content in templates -- I have a single view and use the incoming path as the template path. This keeps each page on the site as a page in the file system (easy to browse, easy to track in revision control), but lets each page share any number of common elements (headers, footers, navigation) and inject its own data into them as needed.
This gets bogged down in a lot of the details, though. For instance:
Sharing of page data with other pages. For example, the title defined by a page should show up in navigation menus on other pages, etc. I found this question about getting a block value from a template, but this seems really convoluted (and not scalable).
Related issue: if I define something as a block I can only use it once. I've seen the example of {% block title %} -- which typically goes in multiple places in a page -- several times in SO without a great solution.
Multiple/flexible inheritance. For a breadcrumb I might want to inherit from a page's ancestor, but for layout I'd probably want to inherit from something else (eg. a one-column vs two-column base template).
I think these specific issues are solvable on their own, mostly by using includes and custom template tags, but looking down that road I see hacks piled on top of hacks, which I'd like to avoid -- this needs to be a fairly simple and easily grokked system.
In the course of looking into these, I came across Hyde, which seems to address a lot of these issues. In particular, I really like that it has a sense of the site structure, and it gives pages some nice tools to navigate.
But I still have all the dynamic pieces, which really need to fit seamlessly. So anything I do for the content pages should really be available for any template that's part of a dynamic application. Also, one thing I really like about the "each page a template" approach is that I can alter the treatment of any particular page just by adding its path to urls.py and specifying a custom view.
Is there a good solution for this type of use case? More generally, is this just something that Django shouldn't be asked to do? It occurs to me that I'm sort of trying to use the file system as a CMS database here, which seems likely to lead to scaling problems, but Django seems to process and cache template content pretty well, and after looking at some existing CMS solutions (django-cms, feincms, fiber) I really don't like the idea of having one solution for static content and a totally different one for interactive content.
Edit
Here's what I got using custom tags to handle page metadata/configuration:
A dictionary for page data is passed in at the top level (so that a tag can write into it and then code higher in the stack can read it back)
A custom data tag allows pages to write data into this page data
Other custom tags read and render structures (navigation, breadcrumbs, etc) from the data
The main piece is a tag that will read data (written as JSON) into the global dict:
class PageInfoNode(Node):
def __init__(self, page_info):
self.title = page_info['title']
self.breadcrumb_title = page_info.get('breadcrumb_title', self.title)
self.show_breadcrumb = page_info.get('show_breadcrumb', False)
self.nav_title = page_info.get('nav_title', self.breadcrumb_title)
self.side_nav = page_info.get('side_nav', None)
def render(self, context):
# 'page_info' must be set someplace higher in the context stack
page_info = context['page_info']
page_info['title'] = self.title
page_info['nav_title'] = self.nav_title
if self.show_breadcrumb:
if 'breadcrumb' in page_info:
page_info['breadcrumb'] = [self.breadcrumb_title] + page_info['breadcrumb']
else:
page_info['breadcrumb'] = [self.breadcrumb_title]
if self.side_nav != None:
page_info['side_nav'] = self.side_nav
return ''
#register.tag
def pageinfo(parser, token):
nodelist = parser.parse(('endpageinfo',))
parser.delete_first_token()
return PageInfoNode(json.loads(nodelist.render(Context())))
Each page sets its data like:
{% block data %}
{{ block.super }}
{% load my_page_tags %}
{% pageinfo %}
{
"title": "My Page Title",
"show_breadcrumb": true,
"side_nav": ["/section1/page.html", "/section2/page.html"]
}
{% endpageinfo %}
{% endblock data %}
This works, but it seems really opaque and fragile:
The global dict needs to be added somehow -- right now I do it in the view, but I guess a custom context processor would be better
This needs to be in an inherited block so that it will actually render
Because we sometimes need the super's data (eg. for breadcrumbs) it needs to call {{ block.super }} but it needs to be in the right order to keep the super's data from overwriting the target page's data.
I just feel like I'm working against the way Django wants to operate, and I was hoping that there was some better way of handling this sort of thing that I was missing.
Stop creating data in your templates. Create it in your views, pass it to your templates. For example, with breadcrumbs, there is no reason whatsoever that the code to add to breadcrumb trails has to live in the template. It could live in a view, or even better, be a context processor.
One solution is to go with a Static site + services model. You use hyde to generate the static site but have your dynamic content dealt with using javascript on the client site and nice REST API on your server.