Custom Template & Rapido Breaks URL Paths - plone

Outline
I have a custom type (Dexterity) called "Gallery Profile", for this type I went into the ZMI (portal_skins/custom), created a new "Page Template" and wrote a custom template for my gallery. The gallery contains a bunch of lower down images and one main image of the owner of the gallery, like a News Item view but a gallery tacked on the bottom.
The customer wants this main image to be published to Facebook when someone hits 'Share' and some more specific info in the title when published.
Work carried out
Configured a Rapido script to write the 'og:image' meta data etc HTML that is required to get this to work (the default Plone stuff only publishes the sites logo unless you're viewing one Image type).
If I go to test the HTML coming out of Rapido via direct web address it works swimmingly. (site.com/##rapido/og_share/block/og_share) - I'm on the slightly older version of Rapido hence the non-plural version of block.
The problem
If you go to my gallery page where we have applied the template, then check the HTML, all of the OG meta data is pointing to the template instead of the current page its on.
This effects queries too (if for example you're using a script to find out what images are within a folder) - it searches /my_template instead of site.com/a_folder/my_template_is_on
In the Rapido Python file I've tried things like:
context.content.absolute_url()
context.content.absolute_url_path()
context.request['URL']
context.request['VIRTUAL_URL']
context.request['ACTUAL_URL']
... and probably more as I've been at this a while.
If you're not on the custom template, it works.
To Reproduce
Create a custom template
Assign it as the default view of a folder or any type.
In your template put <div tal:replace="structure python:context.REQUEST"></div> (just to see the difference)
In your Rapido try using context.app.log() and any of the above
Refresh your templated folder while checking the logs and the output from the context.REQUEST stuff.
You will see the differences and how Rapido is having a hard time getting the URL of the page you are on even though its there.
I've always had this problem with Rapido I just tend to work around it but in this particular situation I am stumped.
So in summary
Am I being an idiot and missing something obvious?
Is this possible?
Thank you for your time.

Related

Linking to a "File type" Dexterity Content Type

We're creating a database of files on a new Plone 4.3.2 website, using eea.facetednav as the main interface. In order to have multiple searchable "tags" plus additional information like publish year, article type, etc etc, we've created custom Dexterity content types for these "files". One of the fields on the Dexterity content type is to upload the actual file.
Everything was going swimmingly UNTIL I realized...
One of the basic functionalities of linking to "files" is now broken. Whereas we would expect creating an internal link to a file will prompt opening the file or downloading it when clicked, now it just takes you to the "view" for the new Dexterity content type, where there's a link to the actual file.
This is pretty cumbersome. Has anyone done this before, or found a way to have it automatically link to download the file? If we need to disable/scrap the Dexterity content type view in favor of the direct link, that's probably fine, but bonus points if you can think of a way to make this work both ways (i.e. have a linking method that takes it to the file and a linking method that takes it to the view).
This is the page I mean by "view", in case it's unclear:
... Off the top of my head, I can think of a weird Diazo solution of making a custom template that parses this view and automatically redirects to the file link, but that seems wrong/weird. Other thoughts?
I'll go for the bonus points, though I haven't fully tested this...
First, you have to designate your file field as the content type's "primary" field. Unfortunately this option doesn't show up in the UI so you have to edit the XML version of the schema (there's a button for this in recent versions of the dexterity control panel). Add xmlns:marshal="http://namespaces.plone.org/supermodel/marshal" as a namespace at the top, and add marshal:primary="true" to the field tag in question.
Then, find your type in portal_types and change the "Default view method" to ##download. (It usually starts out as view for Dexterity content types.) This should make the item's URL download the file rather than showing the normal view. It knows which field to use because you designated it as primary.
You can still access the normal view by adding /view to the end of the item's URL. If you want Plone to do this when linking to the type from navigation and folder contents (just like it does for built-in images and files), go to portal_properties/site_properties and add the type's id to the typesUseViewActionInListings list.
If I had to solve this problem, I'd take the "link" content type view in plone.app.contenttypes as a model.
When someone asks to see a link content type object, the view looks to see if the requestor has the Modify portal content permission on the link object. If they do, they see the conventional view, giving them the opportunity to edit. If they don't, the view returns a redirect to the target URL.
Your code would be simpler. After checking the permission, you'd only need to append ##download/field_name to get the redirect URL.

Manually assigning page META tags to asp.net dynamic pages

I just first want to say, thanks for taking the time to read this!
I have an e-commerce website running the content management system DotNetNuke, which I believe is built on the asp.net platform in a windows server environment. The specific module that powers my e-commerce store dynamically generates pages for each of the store categories, as a user browses through the products available. As you may be aware, modules such as these must be placed on a specific page, and all the dynamic content generated by the module must reside on that "parent page".
The problem is that while the module does allow me to add HTML text for H1's and H2's on these dynamic pages, it does not support adding page meta tags such as "title" and "description". As a result, all of the dynamic pages generated by the module pull their meta tags from the parent page, making it difficult for Google to understand what I'm trying to show the user. This also causes google to show all these generated pages as having "duplicate title tags" in my analytics.
The temporary fix:
I have removed the title tags from all of these "parent pages", in hopes that google will decide to generate it's snippits from the H1 and H2 tags residing on the dynamic pages. Was this wise?
Now for the question:
Is there any kind of solution available which would allow me to manually assign meta tags to a page I specify in my hosting environment? As I stated earlier, I am able to add body HTML code to pages. Is there any way to force a page title tag from code placed in the body? Is there a better way to do this? You can view my problem in action at www.yandasmusic.com
Thanks for your time and patience!
Alex
The temporary fix: I have removed the title tags from all of these "parent pages", in hopes that google will decide to generate it's snippits from the H1 and H2 tags residing on the dynamic pages. Was this wise?
Blockquote
No, not particularly wise. The page title is important.
The first route you should take is speaking to the module developer. They should know about replacing page meta information on a per-product basis.
You can get (limited) results by varying the page title/description using javascript when the page loads. Just keep the js simple and use the DOM information already on the page (ie, read the product name).
I posted a blog about this recently : http://www.ifinity.com.au/2012/10/04/Changing_a_Page_Title_with_Javascript_to_update_a_Google_SERP_Entry
The javascript fix will probably work if you set it up correct. But you really need to convince the module developer to change the way the module works, as bdukes has posted.
Don't bother with the Meta Tags - none of the search engines really read/use them because they are so easily spoofed. Just concentrate on the title and description of the page.
Ideally, your store module should be setting the page title and other meta information. In DotNetNuke, you can access the Title, MetaDescription, and MetaKeywords of the page by casting Page the DotNetNuke.Framework.CDefault type. If the store module doesn't provide this, you should ask the developer to add the functionality.

Concrete5 Custom Content Types (Blocks)

Is there anywhere online where one can find how to create custom blocks in the same way we can create custom content types in Wordpress. The desired result is to add a block that will allow the user to add/edit custom fields like client name, portfolio description, portfolio thumbnail.
I've created a free tool called "Designer Content" that lets you easily generate these custom blocks:
http://www.concrete5.org/marketplace/addons/designer-content
That being said, it is important to understand this key concept: In Concrete5, everything revolves around PAGES. In general, you want to try to establish an architecture where each piece of data is represented on its own page (a "details" page, which would roughly equate to a single blog post in Wordpress). Then you use the Page List block (usually creating a custom template for it to modify its look) to list out titles, links, and excerpts/photos from each of those "details" pages on a top-level "index" page (roughly equivalant to the home page or category archive in Wordpress).
For example, if you're building a portfolio site, you might want one top-level "Portfolio" page that shows a thumbnail and title of each piece, then a "Portfolio Item Detail" page type that contains one piece per page -- each living underneath the top-level "portfolio" index page.
The benefits of this approach are C5 gives you out-of-the-box tools to manage your "data" (pages) in this way -- users can add, edit, delete, and rearrange the pages via the "Sitemap" in the dashboard. Site search works without any modification -- each page (i.e. portfolio piece) will be its own search result with a link to a specific page. Also you then have more fine-grained control over access permissions if you ever decide to restrict access to only certain groups of people (registered users, etc.).
If you take this approach, you might find the "Page List Teasers" addon helpful (it will let the Page List block -- which you're using for your top-level "index" page -- to show actual content excepts from the pages instead of just a separate "description" field):
http://www.concrete5.org/marketplace/addons/page-list-teasers
Or if you want to dive deeper and customize the page list template even more, I have a starting template with a ton of code comments in it explaining how to do different things here:
https://github.com/jordanlev/c5_clean_block_templates/blob/master/page_list/view.php
But... if you're only talking about small amounts of information and you think a separate page for each one is overkill, then the Designer Content approach I linked to first will work just fine.
You can find a HOW-TO on creating new blocks written by Franz Maruna on the concrete5 website.
Here is the link: Creating a New Block Type
There is also a simple block you can download and install to help you follow the developer tutorials. You can find that here: Simple block template

Drupal 7 vocabulary page

I've created a custom page for a specific vocabulary (using zen theme)
page--vocabulary--2.tpl.php
Works so far as I can customise the page, but I cannot for the life of me work out how to render a custom field (field_banner). Very new to drupal, I can find the field at
$page['content']['term']['#term']->field_banner
Basically, on a per 'term' basis, I want to display an array of images (field_banner) at the header of the template. Hope my question makes sense, still overwhelmed by the Drupal way of thinking, so rather confused!
Firstly you need to make sure the field gets loaded on that page. Is it a node ?
What I suggest is you install the dev module and when you see your page you should see dev tab. In that tab you need to find your field set to access. Once you find it in the list then you can access it in your template file.
The code should look something like this
$node->field_link['und'][0]['value']

Drupal 7- How to make a custom module for only front page?

so..I created page--front.tpl.php in my theme directory and it works fine.
now, how do I make a variable that can be used in the page--front.tpl.php?
I can write my php codes inside page--front.tpl.php, but I think there is a better way.
added:
on the front page, I am going to query video and news nodes ONLY. That is why I want to make a new module for only front page.
any suggestions?
I'm not sure what you are trying to achieve here, but OK. You have two options: one is what you're doing now. Write your custom PHP in page--front.tpl.php and you'll be fine. The other is ditching the file and working only with page.tpl.php.
The variable $is_front tells you whether you're on the front page. You can write custom PHP in a conditional block: if ($is_front) { ... }.
Also, you can create a custom block (a view, perhaps, depending on your needs) and set its display restrictions to "only on the listed pages" - and list there. You'll have a custom view loaded only on the front page.
All you need to do have a custom front page is configure your front page in the site information settins (admin/settings/site-information in D6).
Creating a module to display that content is then a completely different thing.
What I would really suggest is looking at Views if you don't know it already. That allows you to build lists of things (nodes, users, ...) and expose them as pages, blocks, rss feeds and much more. You can create a list of nodes with types video and news, expose that as a page and then just point your front page to the path of your view.
you might try using the views module to create your list of videos and nodes. You can set a views page to be your homepage in the site settings.

Resources