I'm new to Social Engine and Zend frame work. I want to customize Header and footer of my application. My default.tpl contains bellow code.
</head>
<body id="global_page_<?php echo $request->getModuleName() . '-' . $request->getControllerName() . '-' . $request->getActionName() ?>">
<div id="global_header">
<?php echo $this->content('header') ?>
</div>
<div id='global_wrapper'>
<div id='global_content'>
<?php //echo $this->content('global-user', 'before') ?>
<?php echo $this->layout()->content ?>
<?php //echo $this->content('global-user', 'after') ?>
</div>
</div>
<div id="global_footer">
<?php echo $this->content('footer') ?>
</div>
</body>
</html>
Now I want load some widgets in footer section. Can any one suggest me how to customize <?php echo $this->content('footer') ?>. And where the footer file located in my application?.
Thanks in advance.
First add a script location to your view and then inside your layout file just use render() or partial() depending on your needs.
ie:
In your controller:
$this->view->addScriptPath('/partials'); // Put your custom files here
In your view:
$this->render('customview.phtml')
See here for more info. Try to use render() instead of partial() as it's quicker
content('footer') ?> in your code calls view Helper Content.php
Content Page calls LoadContent method which collects data from two tables in Social engine
engine4_core_pages table which has a value of 2 as page_id for footer. Based on this page_id (2), engine4_core_content table will be queried, which has the list of widgets that are loaded. For now, one widget is used to display footer in content table is
"core.menu-footer" widget. This widget is loaded in footer area of the template (default.tpl).
Related
Hello and thanks for reading. I am a .NET developer and don't know PHP (Although I am working on learning on the job) and what I am working on was made my consultants that we dont have contact with anymore. When a news post is clicked it appears to display using a template single.php. Followed is the code for this page:
<div id="marketBanner">
<div id="banner">
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/services-banner.jpg" alt="" />
</div>
<div id="breadcrumbWrap">
<div id="breadcrumbs">
<?php
if(function_exists('bcn_display'))
{
bcn_display();
}
?>
</div>
</div>
</div>
<div id="content">
<div class="left">
<h2><?php the_title(); ?></h2><br />
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="the_details">
Posted: <?php the_date(); ?> | View All News
</div>
<?php the_content(''); ?>
<?php endwhile; endif; ?>
</div>
Why does this page get used when a post is chosen? I want only a certain category of post to use this page and another category of post to use a different template. How do I achieve this?
You need to study the Wordpress Template Hierarchy # https://codex.wordpress.org/Template_Hierarchy#Single_Post_display
A template (PHP file) is looked for in this order (only on wordpress).
1 - single-{post_type}.php - If the post type were product, WordPress would look for single-
2 - product.php
3 - single.php
4 - index.php
In your case I would use single.php to create a template for the average post then specifically create a template for the one you want different using single-'post_type'.php
You can change the post type when creating a post.
Take a look at the Wordpress Template Hierarchy. It explains which templates get used and will probably be super helpful if you're just starting out with WP. You can use WP syntax to create category pages - but at the archive level - not the single post level.
To create separate pages based on post categories see here and below:
<?php
$post = $wp_query->post;
if (in_category(9)) {
include (TEMPLATEPATH.'/single-specific9.php');
return;
}
if (in_category(8)) {
include (TEMPLATEPATH.'/single-specific8.php');
return;
}
if (in_category(11)) {
include (TEMPLATEPATH.'/single-specific11.php');
return;
}
I've created a Joomla template (3.2). and my each page type has different class like, All article pages have article class, and contact us page have contact-us class
<!--For About us page -->
<div class='container article'>
...
</div>
<!--For Contact us page -->
<div class='container contact-us'>
...
</div>
and so on.. so is there any way to get this thing done ?
I am not preferring to create a template for each page..
You could get part of the url and if it contains some specific words, you can make an if () else (if ()else()) printing those divs or a case if you want more options
If you want to specifically identify a page type, you'll need to know the component and the view being displayed. If you're in the template file, you can get these like this:
$input = JFactory::getApplication()->input;
$component = $input->get('option');
$view = $input->get('view');
These are just strings so using them as a class is as simple as something like this:
<div class="container <?php echo $component, '-', $view; ?>" >...</div>
Which should give you something like this:
<div class="container com_content-article" >...</div>
When the page is an article view of the com_content component.
First set class name in one variable using different condition and then append this value in class attribute. like following:
<?php
$input = JFactory::getApplication()->input;
$view = $input->get('view');
$container_class=$view;
// also add more condition and set $container_class
?>
<!--For About us page -->
<div class='container <?php echo $container_class; ?>'>
...
</div>
Which approach would you recommend me to use in building "Layout" or "Master" page in CodeIgniter.
Should I create master page view like this
<div id="page">
<div id="header"><?php include "_header.php"?>
</div>
<div id="content"><?php echo $content ?>
</div>
<div id="footer">
<?php include "_footer.php"?>
</div>
</div>
_header.php
<?php echo $title ?>
and controller which sends data
function displayData()
{
$data['title'] = "some title";
$data['content'] = "content page";
$this->load->view('header');
$this->load->view('content', $data);
}
or you use some other technique, I'm coming from asp.net mvc world so I'm trying to grab fast as possible some tips.
Thanks
Codeigniter has a layout library. You can access it here
https://github.com/EllisLab/CodeIgniter/wiki/layout-library. Also, you can approach layouts in Codeigniter using hooks.
I have created a few php files Following are their names:
standard_head.php (which contains basic standard html code)
header.php
navbar.php
sidebar.php
footer.php
standard_footer.php (which contains closing html tags)
Page content will vary in every page and would also include html content.
I am trying to create a lot of php pages which will use all of the above pages directly.
Now I can use them directly using include statement for each of them, but I was wondering if it was possible to include all of them together with one just statement ?
<?php include('../includes/standard_head.php'); ?>
<?php include('includes/header.php'); ?>
<div id="wrapper">
<?php include('includes/nav.php'); ?>
<div id="content">
<!-- my page content -->
</div> <!-- end #content -->
<?php include('includes/sidebar.php'); ?>
</div> <!-- End #wrapper -->
<?php include('includes/footer.php'); ?>
<?php include('../includes/standard_footer.php'); ?>
You could so this (note that this is a very basic example and that I wouldn't use this myself without taking into account meta tags, page titles etc.)
template.php
<?php include('../includes/standard_head.php'); ?>
<?php include('includes/header.php'); ?>
<div id="wrapper">
<?php include('includes/nav.php'); ?>
<div id="content">
<?php echo $content; ?>
<!-- my page content -->
</div> <!-- end #content -->
<?php include('includes/sidebar.php'); ?>
</div> <!-- End #wrapper -->
<?php include('includes/footer.php'); ?>
<?php include('../includes/standard_footer.php'); ?>
Then, on a page (say index.php, for example):
index.php
<?php
$content = '<h1>Welcome</h1>';
include 'template.php';
?>
P.S: If you go down this route, make sure that you check out the Output Control Functions first.
Just create a PHP file that has a list of them i.e.
<?php include("this file");
include("the other file");
?>
And then just add that file.
Not really an answer to your question, but you could use a template engine like Twig.
http://twig.sensiolabs.org/
Try using more complex template system like Smarty or some MVC framework like Zend (this is not required but would allow you to create complex sources more easily) and then build script like this:
<?php include('../includes/standard_head.php'); ?>
<?php include('includes/header.php'); ?>
<div id="wrapper">
<?php include('includes/nav.php'); ?>
<div id="content">
<?php echo $menu->getCustomEntries(); ?>
</div>
Where $menu will be your custom object containing methods for displaying menus and submenus...
There is no straight way to include multiple files, as include / require functions except only one argument. though you can use following logic.
`#include_all_files.php
include('../includes/standard_head.php');
include('includes/header.php');
...
use above file in other files
include('includes/include_all_files.php');
`
how to create a widget out of an existing login action view ?
this is what I currently have in my login.php view file of the site's controller actinLogin()
<div id="login-wrapper">
<div class="login-container">
<?php $form=$this->beginWidget('CActiveForm', array('id'=>'login-form','enableAjaxValidation'=>true,)); ?>
<div class="login-input">
<p>
<?php echo $form->labelEx($model,'username'); ?>
<?php echo $form->textField($model,'username',array('placeholder'=>'username')); ?>
</p>
<p>
<?php echo $form->labelEx($model,'password'); ?>
<?php echo $form->passwordField($model,'password',array('placeholder'=>'password')); ?>
</p>
<div id="bmenu">
<ul class="menu">
<li class="register"><?php echo CHtml::link("Registration", array('wsmembers/register'));?></li>
<li class="login"><?php echo CHtml::submitButton('Login',array('id'=>'login_button')); ?></li>
</ul>
</div>
</div>
<?php $this->endWidget(); ?>
</div><!-- .login-container -->
<div class="login-bg-bottom"></div>
if I click the default login link from the navbar, that's the only time that code above shows
the login box at the upper right corner of the page
but the problem is, the login box should be at the homepage and must already be there
without clicking a login link at the navbar. so how am i gonna do that? this have something to do with main.php layout file right?
Indeed.
What you have defined is a view that is used for content. If you click the link the login action will be executed and it it will show the form.
If you want this to be shown always, just do a Yii::app()->controller->renderPartial on the view. Note that it cannot be $this->renderPartial as you would normally do since the main layout is not executed by the controller. I usually define an alias called "userViews" that points to protected/views so I can do:
Yii::app()->controller->renderPartial('userViews.site.login');
Or something like that. Hope that helps :)
As for the alias you can add this to your config:
Yii::setPathOfAlias('userViews', dirname(__FILE__) . '/../../protected/views');
This is assuming your views are indeed under protected views.