0

I am trying to figure out how to create a page with dynamic content within a block.

For example, a simple "About Us" page may have sub pages of "Contact," "Blog," "History," "Locations"

I would like the Page to remain the same, but only the content within the block change.

So, assuming that from an expanding menu you have the choices noted above. When you click on the "About Us" menu option you get:

About Us

Picture_Default
Text_Default

Now, if you click on the "History" sub menu, you get:

About Us

Picture_Default
Text_Content_Default

History

Text_Content_History


Thus far, I have created a page with the static "About Us" content. I created a Views block with a contextual filter based on Node ID. I also configured the blocks to display only on the about and about/* pages.

When I go to domian.com/about I get the default page. (That works) If I go to domain.com/about/history, I get a "page not found error" where the static content should be and the correct sub page.

I have been searching for this answer and I am sure it has already been answered, but I am not sure if I am using the right terminology to bring up the relevant results. If anyone could point me in the right direction, I would greatly appreciate it.

Thanks!

0

First, what you'll need to do is create the content.

So, for example, if you are going to have the structure:

/about
    /history
    /location

Create a basic page, or any custom content type, for each page (about, history, location). This is where the content will exist, even though you wont access these pages directly. Do not create menu items or URL aliases for these pages - this will be done later. Only create a menu item and URL alias for the about page at this point. The URL alias should be "about" to match the view we create next.

Once you have the content created, create a new view:

  • Show Content of type Basic Page (or whatever type you created the pages with)
  • Check "Create a page"
  • Path: about/%
  • Display format: Unformatted list of full posts
  • Save and continue

So you have a new page view ready to configure. Under "Filter Criteria" add Content: Nid and set it to the nid of the /about page you created earlier. Now, this view basically mimics your about page.

Next, add a new view display attachment.

View Attachment

This is where the dynamic part is done.

Under "Attachment Settings":

  • Attach to: Page
  • Attachment position: After
  • Inherit contextual filters: Yes

Under "Contextual Filters":

  • Choose "Content: Nid"
  • For: "This attachment"
  • Check "Provide default value"
  • Select "Raw value from URL"
  • Path component: 2
  • Apply

Save the view. So the original about page you created at the start should already be accessible at /about if you set the URL alias properly. Now you can access the dynamic content below by visiting /about/(nid). Nid should be the nid of the subpages you created earlier, for example, if the history page has an nid of 2 - you will access it by going to /about/2.

The last thing you will need to do is create menu items for your dynamic pages. Add menu links for each sub page ie.

  • Menu title: History
  • Path: about/2
  • Parent Link: About

Some things to consider: On your dynamic view page, the page titles will link to the original nodes - you'll need to create and use a new display at /admin/structure/types/manage/page/display to remove the linking. Then update your page view to use the new display under Format -> Show -> View mode

  • This was more than I was looking for and it accomplished in about 10 mins what I have been searching for and experimenting over the last two days. I just have to keep in mind that you have to clear out or refine the "criteria" fields to match your content types and node ids on the "attachment." – Allan Feb 28 '15 at 21:10
0

First create a taxonomy whose terms will be those 'contact', 'blog', 'history', 'locations'.

Then create a views page with contextual filter based on term id and set path as about/%

  • I am trying to avoid taxonomy altogether in my site as I learned that it isn't a very efficient data structure. – Allan Feb 28 '15 at 19:07
0

I would experiment with Quick Tabs. What you're looking at is creating simple nodes, and Views might just be a bit of overkill here.

  • Well, there's more to it than this page. This is just the beginning. Besides, I welcome the opportunity to learn how to implement Views properly. – Allan Feb 28 '15 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.