0

I created a view and a page display of it. I set a path for it. this is its path

http://localhost/myProject/library

but when I copy and paste this url in address bar, it just displays my page.tpl.php what I have created for front page. why?

2 Answers 2

2

Your issue seems to be in the file name - page.tpl.php will be used automatically for display of all pages.

If you want to have separate template, use hook_preprocess_page():

function MYTHEME_preprocess_page(&$variables) {
  if (arg(0) == 'library') {
    // This will look for template named page--library.tpl.php in your theme.
    $variables['theme_hook_suggestions'][] = 'page__library';
  }
}
2
  • thanks. do I need to add any special code inside page--library.tpl.php to display views fields ?if I want to embed this view in a special region of this page what shall I do? my method for doing such thing is this code views-embed-view() and I write this code at any place what I want to display the view.
    – M a m a D
    Oct 14, 2013 at 7:00
  • 1
    No, you don't need any special code to display views fields. Just copy the page.tpl.php and make necessary adjustments to the layout. The second part of the question is not quite clear - I suggest creating a new "Question" here so the answers are separated for other people with the same issue. Oct 14, 2013 at 7:22
0

Are you providing this complete path as "http://localhost/myProject/library".If so please provide relative path instead of absolute path, so relative path would be "library" only and then check again visiting http://localhost/myProject/library in your url.

1
  • in views interface I only write library
    – M a m a D
    Oct 14, 2013 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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