How to navigate between a specific group of posts in wordpress - php

I am building a website for a school using wordpress. What is the best way to construct the classes and the students for each year? And what is a good way to display them and navigate between each year and show the classes for each year?
I tried showing them all on the same page. But i want to categorize each class with its specific year and navigate through each year.

I assume every student has it's dedicated profile page.
If you want to use the default Wordpress hierarchy,
You can start by setting the pages dedicated for classes
Then you can set the year number as a category (or tag) for each class
Then for each student' page, you can set it's class page as a parent page. Using the page attributes like here
Later you will list all categories links in the main page.
But if you expect a custom design, like a timeline or a tree or a big hirearchy chart, you need to use page templates with custom queries.

Related

Navigating through custom post types in WordPress

I want to redesign my website using WordPress (as CMS) and Bootstrap (as front-end).
Now, I've been pretty successful at doing so, but I have one specific problem.
I have a tutorial website and I want the navigation structure to look like this :
If the user is on my 'website-name/tutorials' then display to him all of the tutorial series titles in an unordered list (so for example C++, XHTML and CSS - but not individual tutorials in each series)...
If the user clicks on some specific serie, then display an ordered list of the elements (so, if he clicks C++, then URL will be 'website-name/tutorials/cplusplus' and he will be able to see all of the tutorial in an ordered list).
If the clicks on one specific tutorial, then the URL goes (for example) 'website-name/tutorials/cplusplus/installing-the-program' and user gets all the content related to the tutorial.
Now, I have been experimenting with this and concluded that the best solution is to create custom post type named "Tutorial" and then make every single tutorial that post type.
However, since on 'website-name/tutorials/cplusplus' I want to display the list of tutorials in "C++" tutorial series and on 'website-name/tutorials' I want to display only the tutorial names, I don't know how to do that.
I tried to do that using Hiearchical posts (so, for example, I made a parent post named "C++" and it's children were all of the tutorials in the C++ serie).
However, I have a problem with that, because my C++ tutorial series has 100 tutorials, but it shows me 101 list elements (I made the website display all the custom post types in an ordered list), with the first one on the list being C++ (the parent post).
So, I'd like to echo the series name only on the 'website-name/tutorials' not on the beginning of the list.
I researched and people seem to use archive in custom post types, rather than parent/child system for this kind of navigation.
I just wanted some of the WP experienced users here to tell me, which is the better solution for my problem? Dealing with these parent/child problems or switching from parent/child posts to archive posts?
If I understand fully perhaps using standard posts and categories will do the trick? Your '/tutorials/' page can display the full list of all posts and when a user clicks on a specific category (e.g. C++) only the relevant posts will display.
You can use the following code to list posts of a specific category:
<?php query_posts( 'cat=20' ); ?>
Changing "20" with the chosen category ID.
Hope this helps!

list all products and link each category grid with category box in opencart

I want to load all categories grids on one page and want all products to be available on scroll down. currently I need to click on each category and the page refreshes for each category. This is the site I am working on(ahmad.esy.es). I want this type of functionality upon clicking the category(http://www.just-eat.co.uk/restaurants-hertsplaice-en11/menu#2254). kindly suggest me what changes should I make in view files (product.tpl, category.tpl) or controller files(product.php, category.php). how can I load all the grids of categories in one page
I didn't look at the site you have posted above - if you cannot describe your issue by words or by submitting a code or image it should be improved.
From what I understand you just want an infinite scroll to display all the products you have in your eshop. It is not mentioned whether you want to preserve the default functionality (category tree with products attached to certain categories) or whether you want only this one listing - basically it does not matter - so I will describe in short how to add such new functionality.
The model
you do not need to touch any model - you can reuse the method ModelCatalogProduct::getProducts()
this will give you the possibility to sort or filter the products except you will have to omit the filter_category_id to load all the products
The controller
feel free to create a new controller (e.g. ControllerProductInfinite) or just to reuse one of the already existing - either ControllerProductCategory or ControllerProductProduct
all you need is basically the same as in ControllerProductCategory::index() except adding filter_category_id into a array passed when calling ModelCatalogProduct::getProducts() and a new template for rendering
The template
create a new template that will meet your expectations and infinite scroll requirements
stick to any infinite scroll plugin/implementation you like (may Google be with you)

MySQL table relations, inheritance or not?

Im building a micro CMS. Using Mysql as RDMS, and Doctrine ORM for mapping.
I would like to have two types of pages. Static Page, and Blog Page.
Static page would have page_url, and page_content stored in database.
Blog page would have page_url, but no page_content. Blog would have Posts, Categories...
Lets say I have route like this:
/{pageurl}
This is page, with page url that can be home, or news, or blog...
That page can be either Static page, and then I would joust print page_content.
But it can also be Blog Page, and then I would print latest posts as content.
How should I relate these Static Page and Blog Page tables?
Is this inheritance, since both are pages, with their URL, but they have different content?
Should I use inheritance, so that both Static and Blog page extends Page that would have page_url? Or should I made another table page_types and there store information about available page types?
Generally, and I'm speaking with a MVC framework in mind, when you use routes you would have a specific pattern that you can match to different controllers/actions that could then map to different models and views.
For instance, a standard page URL would be in the format:
/{pageurl}
Whereas a page URL for a blog page would be:
/blog/{pageurl}
This would make it very easy to distinguish between the two and route accordingly. If it matches the pattern /blog/*, it's a blog! However, let's assume you don't want to take the easiest method - but instead decide to have all URLs follow the same pattern: /{pageurl}. Your actual list of URLs should all be stored in a single table in the database, let's say it's named site_pages. The relationship between your site_pages and blogs would be a column in blogs named page_id that is a foreign-key back to the site_pages table.
With this, you have a few ways you could determine what type of page you're looking at:
Add a new column to site_pages table, such as is_blog; it it's set, you have a blog!
Every time you look up the page in the database, also get a count() of blog entries for the specific page; if it's > 0, you have a blog page. Otherwise display it as static content.
Make an assumption that if page_content is empty, it's a blog.
Once you have established if the page is a static page or a blog page, you could load a corresponding Model - "Page" or "BlogPage". BlogPage can, and probably should, extend Page since they have the same purpose. The only difference between the two is that "Page" just loads the page's text-content and the View simply writes it out. The "BlogPage", on the other hand, would load the list of Categories, Posts, etc and the View would iterate through them and display them however you see fit.

How to handle the subpage concept under Yii?

This is a very newbie question so bear with me. I'm starting to use Yii as my first PHP framework and so far so good, the project on wich I'm learning is a simple informative webpage, but how am I supposed to handle the subpage concept under Yii? This is what I'm trying to achieve:
Home
Products
Product 1
Product 2
Contact
I have a controller for Home, Products and Contact, now I know that Yii doesn't work with subcontrollers, then how do I create a Product 1 and 2 subpages? Just a different view for each one? Through Gii? Many thanks.
You could do one of two things
You could have a generic product page that accepts a parameter to distinguish between different products (common approach). For example,
www.mysite.com/products?id=1 would show Product1's page whereas www.mysite.com/products?id=2 would show Product2's page (and if there is no id parameter in the query string, then you could just show your Product page)
And you could also have separate methods for each page. So you would have
actionProduct
actionProduct1
actionProduct2
methods in your Product controller and then you could reach your pages as
www.mysite.com/product
www.mysite.com/product1
www.mysite.com/product2

Drupal route based node content

I'm new to Drupal and have a basic question which I cannot find a good answer to. I am trying to dynamicly determine the contents of my website based on a selection made by the user and keep the selection displayed in the routing for SEO purposes.
It's a website for a Restaurant with multiple franchises.
What i'm trying to do is the following:
The user visits my website and gets a splash screen presented with the available franchises or a textbox to enter his postalcode
Upon selecting he enters the main website with the navigational structure adapted to the selected franchise. For example: domain.com/city/, domain.com/city/menu, domain.com/city/menu/dishes, domain.com/city/contact, ...
The contents of all nodes are based upon the city the user selected. Some franchises have extra nodes which should be displayed in the main navigation aswell.
What I have thought about so far is to try to accomplish this with taxonomy but I really have no idea where to start. Parts of the nodes will be the same for all franchises other parts will be different. Menu item prices will also be different.
This is the first website i'm building using Drupal so any advice is welcome.
Thanks!
It will be impossible to explain it all here but yes it is possible to select your content based on user input in Drupal. You will need to look into Views & Panels.
In Views you can use arguments to narrow to a specific taxonomy. With Panels , an argument can be retrieved fron the URL and passed to the Views in order to display the results.
There are a lot of resources available, Merlin of Chaos, the author of the Views & Panels modules has written a book about it. There are video tutorials online. Your best bet is to start with drupal.org.

Categories