Just a simple question on Kentico: Is it possible to exclude some pages from rendering the CMS breadcrumbs?
Specifically, our users want the homepage not to render any breadcrumbs so I'm trying to exclude that.
This is kinda tricky. But if you ensure that breadcrumb control has no data you can hide it via 'Hide if no record found' settings.
Set WHERE condition of the Breadcrumb web part to the following macro:
{% if(CurrentDocument.NodeAliasPath == "/Homepage"){"1=0"}else{"1=1"} #%}
Obviously, you have to use node alias path of your homepage.
Set 'Hide if no record found' to true.
Related
I am trying to create a custom archive template for my categories. I have a parent category called
member-resources, which is a parent category for multiple other categories.
I do not want to access these categories by /category/member-resources.
According to wordpress documentation for template hierarchy, I need to create archive-member-resources.php and change the php code to display as needed.
However this template is not the one being rendered(archive.php is always being rendered), and if I try to access it by entering /member-resources I get a 404..
What am I missing ? thanks
[EDIT]
Excuse my wordpress skills as I have only been working with it for about a month..
I asked this question for a very simple reason. I worked on a project, in which I ended up with a massive archive.php file with alot of conditional logic such as :
if( is_category('events') ), render a side menu
if( is_category('news') ) , render something else
if( is_category('member-resources') ) render pagination
This is just an example, but I wanted to highlight that with different categories, I might want to call a completely different archive template( if at all possible ), rather than having a large file which is not very maintainable..
If this cannot be done, please provide me with a solution, so that on my next project, I wouldn't run into this problem again.
You should not use any type of archive page (archive.php, category.php, taxonomy.php etc) as a listings/index page. That is not what archive pages are intended for. Also, the template hierarchy specific to archive-xxx.php is for custom post types, not categories.
The main query on any archive page is quite specific and should not be tampered with on template level. It totally destroys pagination and common logic within the main query.
You should make use of a page template. Just simply copy your page.php, rename it to page-xxx.php, add the necessary page header and modify it as needed
For further reading
Page Templates
WP_Query
I have a custom post type (that I'm using on a template page), the custom post type is called 'Headerhome'.
When I post say a gallery there I'm trying to get it to redirect to 'single-Headerhome.php', yet it always just goes to 'single.php'.
The name of the custom post type itself is arbitrary, the name of the templage page it's on is 'home'.
I'm really confused, I'm not the best at WP yet so when something simple like this doesn't work I have no idea how to fix it, even after pouring over the codex for an hour.
The name of the custom post type itself is arbitrary, the name of the templage page it's on is 'home'.
Reading this implies that you have a home.php file in your theme, which would automatically display as your front page of your site. This may not be what you desire? More on this here: http://codex.wordpress.org/Creating_a_Static_Front_Page
An example of a custom post type might be an Event. The Event might have custom fields associated with it, like Location, Date, Time, Description. We would probably want new Events to show up on our front page, but also would want to create a custom theme file so when a user clicks on an Event from the home page to view the Event then the Event page shows our Date, Time, Location, Description, etc. We would then create a single-event.php to do this and put in any custom code their.
So (another example), a custom post type of Fruit would have an associated theme file of single-fruit.php. If their is no single-fruit.php then Wordpress will use single.php as the default theme file to display. More on this here: http://codex.wordpress.org/Post_Types#Template_Files
Hope this helps set you in the right direction.
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.
I want to display a block of my view on the front page.
This block will have exposed filters.
Once the filters are filled in by the user and he/she submits it
I want the user to be redirected to the results page which the results instead of showing them the results on the same page.
How can I get this done ? Do I need to use panels for this? I am not sure.
In fact this is quite simple.
You just have to define your page's exposed filters as an exposed form block in your display's advanced options then put this block where you want on your front page.
You can also get more options for the exposed form with the 'Better Exposed Filters' module
Easy Vishal - use the block's display properties to do this.
To restrict block to home page only use 'display only on the following pages' and add . To do this the other way around and put it on all pages except your view you would fill in 'display on all pages except' and put in your view url (ie view/listing-of-stuff)
I wonder if there's a Drupal module that can do this kind of functionality: if i go to home page, it will take me to some subpath within the site. i.e. www.something.com will redirect to www.something.com/product/node/11.
I tried creating an alias and used Path redirect module but for some reason, i can't reach the expanded URL when going to home page. it will display the content of www.something.com/product/node/11 but still using www.something.com.
I'm thinking that this can only be implemented in Apache server, not inside Drupal?
Note that our purpose of doing this feature is whenever a new product is created, we want our home website to point to that (i.e. www.something.com -> www.something.com/product2/home, before www.something.com/product1/home). If this is configurable inside Drupal, the changes would be easier and can be done by a Drupal administrator.
You should be able to go to /admin/settings/site-information and set the Default Front Page at the bottom of the form. That doesn't do a redirect: the home page will BE whatever you set the default to.
Create a new view (Node type) named "frontpage_redirect"
As suggested in answer by Michael D, create and save a view configured to search for your specified criteria:
display: page display, path = frontpage-redirect
pager: 1 item
row style = Fields
fields: Node => Node ID
filters: node type = product
sort: post date desc
Save your new view
At admin/config/system/site-information, set your "Default front page" to the view display path above (frontpage-redirect in my example)
In the view edit screen select "Theme: Information" link in the Page display. Look for the most specific (rightmost) entry under "Field Node: Nid (ID: nid)" - should be something like views-view-field--frontpage-redirect--page-1--nid.tpl.php, but will depend on the view name and display name. Copy the default views template views-view.tpl.php into your theme folder using the filename from 3.
Edit the template and put this code in it:
if (isset($row->nid)) {
drupal_goto('node/' . $row->nid);
}
This way of setting up the redirect lets you drive it from Views, which gives flexibility. When your customer decides in six weeks that they want to feature only the latest red product on the frontpage, you'll be able to update the logic behind the redirect using the views UI. (And you can do it from your phone on the train home!)
You avoid the need to create a custom module (which is easy enough, but does add some complexity) or to move your site logic into .htaccess.
Using the Views module, create a new view that displays one full node, ordered by last created, filtered appropriately, then create a page display in the view. Then follow Graham's instruction to set the site homepage to the view URL.
Another way would be to write a very simple custom module that db-queries for the latest node created of the sort you want, grab the URL to the page, then redirect there using drupal_goto().
There are other ways to do what you want inside Drupal, but I can't think of any that are more direct and simple at the moment...
What you are asking seems wrong. Sorry if I misunderstand some detail, but it seems you should reconsider the problem on a higher level.
If I understand you right, you want to show the page for the latest product as the homepage?
If so, maybe you should turn that into show the latest project page on the homepage. That fits a lot better with the RESTfullness of the web. And with expectations of the users.
The pattern would then be:
GET /products/22 shows product 22
GET /products/23 shows product 23
GET /product/latest shows the last product (in this case, the page would be exactly similar to /products/23)
To achieve that, you can use views module.
On similar lines to Michael D's post, assuming you want to pull the most recently published product from a custom content type called "products," you could put something like this in your settings.php:
function yourtheme_preprocess_page(&$variables) {
$query = db_query("SELECT nid FROM {content_type_products} ORDER BY nid DESC LIMIT 1");
while ($row = db_fetch_object($query)) {
$redirect_nid = $row->nid;
}
if ($variables['is_front'] == 1) drupal_goto("/node/" . $redirect_nid);
}
modify the .htaccess file.
http://drupal.org/node/50322#comment-2456576