I'm new to Mezzanine, but I've got a project up and running and can generate customized Pages using my own model. I'd now like to group these pages into sections (and maybe subsections) like this:
Section1
Subsection1
Page1.1.1
Page1.1.2
Subsection2
Page1.2.1
...
Section2
Subsection1
Page2.1.1
Page2.1.2
...
and so on. How can I attach my Page objects to specific Section and Subsection categories (with an index page for each?) Do I need to create another Model to represent these categories and then a page_processor to generate the index or is there an easier way?
In Mezzanine, your categories of Section1, Subsection1, etc. need to be pages as well.
Say you wanted the following structure:
Movies
Comedies
Monty Python and the Holy Grail
You would first create a Mezannine Page (or RichTextPage or similar) with title "Movies", and enter some content (even if minimal), such as "These are the movies I watch too much". This page will automatically contain links to any subpages once you create them.
To create a subpage like "Comedies", you would go to "Pages" under "Content" in the admin, and click on the "Add" dropdown menu in the "Movies" row you just created (and not the "Add" dropdown at the top-right of the page).
Follow the same pattern to create a subpage under "Comedies", and on that page ("Monty Python...") you'll likely enter the bulk of the content you actually want.
If it suits your needs, you can consider the other hierarchical pages to be nothing more than placeholder pages in a way, but those pages are usually a place to put content related to what the category itself is about.
The overall page structure will be mirrored in things like navigation menu dropdown trees.
Changing the structure of existing pages:
The Mezzanine Admin > Content > Pages page supports drag & drop for this.
Click a page's row near the right side (where the small up/down arrows are), and drag it to where you want it to go. A dotted outline will appear indicating where the dropped page will go, as you move the mouse around.
If you want to move your existing page to be a subpage of another, you can position the dotted outline below the intended parent page, and then move the mouse right or left before dropping the page. You will see the dotted outline's position change from indented to de-dented. Dropping while the outline is indented will create a subpage.
Note that the right/left mouse adjustment to get the indent/dedent might be somewhat finicky, depending on the mouse's position.
Related
I am currently working on a project that scrapes content from a dynamically generated page and records it.
The below is an example of the structure I am pulling from.
https://dutchie.com/embedded-menu/revolutionary-clinics-somerville/menu
I am able to scroll down the page and locate the specific details from each product card, using:
cards = driver.find_elements_by_css_selector("div[class^='product-card__Content']")
From each card, I am able to pull the title, price and other variables and store them as needed.
The problem is that I want to append to these the "category" which happens to appear as a header above each grouping of items, example from above being flower followed by prerolls. As the page scrolls down a new one of these is displayed followed by the related item.
I have been able to access the first instance of this, but no matter where I put the following code in my loop it never pulls the updated value, only the initial.
category = driver.find_element_by_css_selector("div[class^='products-grid__ProductGroupTitle']").text
I tried to figure a way to pull this as the parent/ancestor of the current card, but this concept is still new to me and outside my understanding of how I would solve it. Is locating the "nearest" ProductGroup title the correct approach? If so how would I do so dynamically as the page scrolls?
Thanks!
To grab all the product group names, you can use a CSS selector
div[class^='products-grid__ProductGroupTitle']
NOTE: ^= in a CSS selector means starts with
From there we can insert the product group into an XPath and find all details for each product under that group.
# loop through all the product names
for product_group_name in driver.find_elements_by_css_selector("div[class^='products-grid__ProductGroupTitle']")
# loop through each product card
for product in driver.find_elements_by_xpath("//div[starts-with(#class,'products-grid__ProductGroup')][./div[starts-with(#class,'products-grid__ProductGroupTitle')][text()='" + product_group_name.text + "']]//div[starts-with(#class,'consumer-product-card__InViewContainer')]")
# get individual product info
brand = product.find_element_by_css_selector("div[class^='product-information__Brand']")
# if you use an XPath, make sure you include a dot (.) at the start of the locator
# brand example using XPath
brand = product.find_element_by_xpath(".//div[starts-with(#class,'product-information__Brand')]")
title = product.find_element_by_css_selector("div[class^='product-information__TitleContainer']:not(.mobile-and-card)")
# ... and so on
The problem is... that page is broken so no code will likely work until it's fixed. If you look in the dev console, you will see repeated error messages.
[mobx.array] Attempt to read an array index (0) that is out of bounds (0). Please check length first. Out of bound indices will not be tracked by MobX
Every time that message fires, the page seems to lose track of elements on the page.
You can use this xpath -
//div[text()="Flower"]/following-sibling::div/div
Just change the text "Flower" with your other categories and you will find all the cards under certain category.
I'm trying to automate my spendings&budget, but the website of the bank reveals/hides the element I am looking for, depending on the scroll height.
Example
This is when I am at the top of the page:
And this is when I scrolled a little:
Problem
I am trying to get all elements in this role='transactions-group' but, when I added an option for scrolling:
driver.execute_script("window.scrollTo(0,document.body.scrollHeight)")
transactions = driver.find_elements_by_xpath(
"//div[#role='transactions-group']")
print(str(transactions[0].text))
it just loaded everything, but it continued to find the items that in this case were on the bottom of the page.
So my question is: Can I do some kind of loop or something to fix this problem?
I'm trying to create and add pages manually to a PDF file, using Python 3 and reportlab.
I can easily create the first page, and draw on it. But I don't know how to manually add new pages.
Example:
from reportlab.pdfgen.canvas import Canvas
canvas = Canvas(pdf_path, pagesize=(WIDTH_OF_PAGE1,HEIGHT_OF_PAGE1))
canvas.rect(100,100,200,200,fill=1, stroke=1) # draw on the first page, this is just an example...
# Now create and add a new page here, but how???
canvas2.rect(200,200,300,300,fill=1, stroke=1) # draw on the second page, this is just an example...
# Finally, save the PDF
canvas.save()
How do I start a new page of a specific size?
Please note that I'm not using Platypus. These pages don't have a fixed height. Every page will have a different height, that is pre-calculated by some algorithm. So the concept of "flowables" cannot be used here, and I need to add pages of specific (different) sizes to a PDF document.
A workaround solution could be to create a separate PDF file for each page, then concatenate them with an external program, but I don't like that idea.
Finally, I figured out how to create a new page. It is mentioned in the reportlab documentation, I just did not notice.
canvas.showPage() #Close the current page and possibly start on a new page.
There is also a solution for changing the page size for individual pages - this is something that Platypus cannot do:
canvas.showPage() # Close the current page and possibly start on a new page.
canvas.setPageSize(A3) # Change size of the current page
I am quite new to wxPython and want to build a wizzard. I used this guide as a base ("wxPython: How to Create a Generic Wizard"). I tried to add some widgets the panel, e.g. some radio buttons at the second page by inserting the following code at line 56 in add_page():
if(title=="Page 2"):
k1=wx.RadioButton(panel,-1,'Argument1',(35,60),(150,20), style = wx.RB_GROUP)
k2=wx.RadioButton(panel,-1,'Argument2',(35,80),(150,20))
But as soon as I try to add some sizer to the the second panel, all pages are affected. I tried quite a few variations of where to place the sizers, but without success. So my question is: is this the appropriate place to modify the individual pages and could someone give me a hint of how to write a minimalistic example of e.g inserting a boxSizer and a button in the first page and a boxSizer and a RadioButton in the second page?
As a CMS, Plone receives contents and display these contents organized by menus in an initial "home" page, where you can browse other pages and other types of contents.
Is it possible to make a menu item to point to a second home page in the same plone portal?
Today I discovered that we can select a page or other type of content to replace the landing page of a folder. It's almost what I want. If I could make this page to show the news from that folder, and some other contents well designed in table like the "Initial page", that would be the goal. I believe I would need a portlet to make a new kind of content or make the 'page' to mimic an 'initial page'
It is different from creating a simple page linked to that menu, where there will be only lists of contents and widgets at most.
The case study is a Plone portal of an government office, and the subsection that wants to have it's own "home index" is the human resources division.
I need a real new 'home' page as if it was a home for an entire (and important) subsection of my portal.
If it is possible, will I need only administrator skills or will I have to alter some python code or config file?
This is the initial (home) page, the index of the Plone portal
This is the standard page of a menu root, having the content list for it's submenu items
This may well be possible. What you are really asking for is a "portal like view" on another folder in Plone. This doesn't come as standard in Plone, so what you've got working on the homepage indicates either:
a) you have an addon such as collective.portletpage or collective.cover (as #kuel suggested)
b) a Plone developer has set you up a custom view for your homepage
If it is b) then you will probably need help to tweak it to your needs for the HR folder, otherwise you should be able to do most of what you want on your own, by just adding a "Cover" or "PorletPage" (or ....) type as the default page for the HR folder.
The reason we are struggling to give you a perfect answer is that we don't know which addon or custom view you are using for your homepage. This is why I asked for the body tag. To get that (assuming you are using Firefox) just right click on the page and select "View Page Source", then press Ctrl-F for the Find menu and type body into that field. Just copy 4 or 5 lines around there to let us help you more!
Alternatively (though less certain to work) just click on the "Add New..." menu and list what types are available and we may be able to tell you what type to add.
What you want is really well implemented by collective.cover addon: https://github.com/collective/collective.cover/#don-t-panic
It's used by many brazilian federal government websites such as Brasil.gov.br, Planalto.gov.br, Secom.gov.br and also by the project https://identidade-digital-de-governo-plone.readthedocs.org/
Also you should join PloneGovBR community: https://colab.interlegis.leg.br/wiki/PloneGovBr
Happy Ploning! :)
You can use Products.ContentWellPortlets to assign additonal elements above and below the landing page. In case you don't want an element in the middle of the grid-/dashboard-like layout (similar to http://[HOST]/[PLONESITE_ID]/##dashboard), leave all fields of the landing page empty, but the required title, and hide the title via CSS.
EASI.
You should only try this if you have Zope administrator access.
Go to the URL:
/portal_skins/plone_login/logged_in/manage
In there you will see a line of code identifying the user:
member = membership_tool.getAuthenticatedMember()
Copy that line.
Now go to the URL:
/portal_skins/plone_login/login_next/manage
...and click on the Customize button. This will give you an override copy of "login_next" that you can edit. (At any point you can delete this copy and you will revert to the original.)
Now look at the end of the routine where a line begins with:
state.set(came_from=came_from, next=next)
You will see a variable next being set to the URL that the server will go to next. Now if you paste your member = ... line just before that, you can set the variable "next" to the HR homepage URL, for cases where member is in HR.
There is probably a Group to which HR people belong, but that's a slightly different question. Please see docs at: http://docs.plone.org/develop/plone/members/member_basics.html
Remember, just delete your customized copy of login_next to revert to the original.