Programmatically render 404 in single page in concrete5 (version 7) - concrete5

I've got a single page, where it checks a slug. If this slug can not be found in a database table, the single page should render the 404 page.
Something like this I have tried:
$this->render('/page_not_found');
Now, this goes to your active package single pages directory (packages/your_pkg_handle/single_pages/page_not_found.php). It should go to the active theme instead though... I have tried setting the second parameter to "null", as I thought that would be the pkgHandle, but no result. Obviously I'm missing something or this is not possible?

Try
$this->replace('/page_not_found');
instead.
This is a little convoluted, but the reasoning behind this is $this->render() actually renders the view with the current controller (which will mean looking into the package for the view), whereas $this->replace() will replace the rendering session entirely with a new controller, view and exit output.

Related

NEXTJS Dynamic routes return 404 no matter what

I'm trying to reach http://localhost:3000/nba/category-slug-3 but I keep getting 404 error. http://localhost:3000/nba works fine but any slug does not work. Am I missing something? Do I need to add/edit another file? I just started using NextJS. At some point I want to be able to use item id's from a mongodb collection as the slug.
It looks like you named your page [slug.js] when you may have meant to name it [slug].js.

Custom Template & Rapido Breaks URL Paths

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.

DjangoCMS Plugin Tutorial: Poll Plugin list shows `poll object` for list of options

I went through the plugin tutorial, as well as the preceding few, but it seems like there's a bug while trying to add a plugin.
On a page in Structure view, I have an empty placeholder. I click +. Click on Poll Plugin, and a modal pops up with a <select> that seems to have been generated through xhr at this route:
/en/admin/cms/page/add-plugin/?placeholder_id=13&plugin_type=PollPluginPublisher&plugin_language=en HTTP/1.1
Inside of that select is <option>s with "Poll object" for each poll that I've created. I choose one, and press save. The object shows up as a plugin for the placeholder. The odd part is that the correct __str__ (I use Python3, so I'm not using __unicode__) is being used here, which was gotten from the route /en/ HTTP/1.1: "Which browser do you prefer?"
Why is /en/ giving me the correct string representation of the PollPluginModel, but when using the Add Plugin modal /en/admin/cms/page/add-plugin/?... I get the Poll's string representation?

Wordpress Page Hierarchy

I have the following page on a site in development:
http://telamon.com.s137737.gridserver.com/media/press/
I want to do some stuff outside the loop, so I created page-press.php based on my understanding of the WP page hierarchy (http://codex.wordpress.org/Template_Hierarchy). It isn't working. I've reset permalinks as well. This isn't the first time I've had problems here and I just ended up creating a template, but this should work shouldn't it?
Yes it is true that the hierarchy should work like that, but for it to work you need the following to be true:
It needs to be in the Single mood
The page need to be a static page
You can't apply any other custom template on the page
The slug of the page needs to be "press"
If all of these are true, then it should work. If not, then check the following, find the id of the page and create a page-$ID.php and check if that works. See if you end up in the page.php template file, or if you end up in index.php try to use var_dump on a few variables like is_single() and so on.
EDIT:
Single mood is when the page is listed by it's own, not in a list.
Static page means this is not a post, or a list view like archive or something like that
Custom template is when you create a page to be a specific "page template" available to choose from, when you edit you page (down right).
Slug is not the same as your title, nor you id. It's most likely a url friendly variation of your title.

taxonomy/term/% says "page not found"

Currently, all URLs to taxonomy/term/% say "page not found."
Here's what i did the last minutes:
My taxonomy view consisted of very large entry;I just did the usual customized taxonomy/term/% view: I first duplicated the original one, and then I deactivated it.
In my custom module, in hook_nodeapi(), I checked if the current URL is /node/*, and in the case it's not (e.g. it's a taxonomy view), I skipped my custom additions (lookup content in a file). It worked fine, with small "teaser" entries on the tax.page.
I changed the page size in view, increased it, and exposed it. Then I recognized some minor things that were not well done, deleted the view, and recopied it again.
Now all URLs to taxonomy/term/% say returns the "page not found" error.
I can't figure out why. The cache is cleared, and I am logged in as administrator.
Preview in Views UI works fine.
Had active a second view with the path defined...

Resources