I'm new in programming zend and socialengine. I have default.tpl layouts like the following:
<body id="global_page_<?php echo $identity ?>">
<div id="global_header">
<?php echo $this->content('header') ?>
</div>
<div id='global_wrapper'>
<div id='global_content'>
<div class="new class contain widget">
</div>
<?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>
<div id="janrainEngageShare" style="display:none">Share</div>
</body>
I want to add/call widget and place it inside <div class="new class contain widget"> </div> tag. For example, I want to add widget menu main and search widget from Core Module inside this html tag, How can I achieve this? Need your help.
It is quite simple.
Use the following code, replacing the core.menu-main with name of your widget:
<div class="new class contain widget">
<?php echo $this->content()->renderWidget("core.menu-main"); ?>
</div>
Related
I have setup a small webstore and I want to show this <div class ="data-plan"></div> only for one single product. My database table from where I want to match this id is called sb_files and it has these fields id table_id path type slide_link, so I am trying to get my code to go trough that table, search up the id ( Its 13040100 ) and if it matches then to show the div, else it shows an empty div. I am using the Yii2 framework, which is php based. So far I have tried this
<?php if($product->$this->id('13040100')): ?>
<ul>
<?php
$index = 1;
foreach($product->() as $prd):
if(strpos($prd->getPath(), '13040100') == true) {
?>
<div class="wrap">
<div class="data-plan" style="height:20px; width:65px; background-color:#00a651; float:right;color:white;margin:10px;text-align:center;">A+++ </div>
<div class="data-plan" style="height:20px; width:65px; background-color:#ed1c1c; float:right;color:white;margin:10px;">Datu lapa </div>
</div>
<?php
$index++;
}
endforeach;
?>
</ul>
<?php else: ?>
<div class="wrap">
</div>
<?php endif; ?>
I'm not that familiar with Yii2 framework myself, but are you sure that $product->$this->id('13040100') is correct? It looks weird to me, shouldn't it be something like $product->id('13040100')?
The solution was way easier than I tought, just had to think simple
<?php if ($product->id == '13001100'): ?>
<div class="wrap">
<div class="data-plan" style="height:20px; width:65px; background-color:#00a651; float:right;color:white;margin:10px;text-align:center;">A+++ </div>"
<div class="data-plan" style="height:20px; width:65px; background-color:#ed1c1c; float:right;color:white;margin:10px;">Datu lapa </div>
</div>
<?php else: ?>
<div class="wrap">
</div>
<?php endif;
Apologies, I am relatively new to PHP and am learning as I go, but am stuck on this... I have this template for a page-title section with a background image. I can add the background image, but if there is no background-img:url elected on the page, is there a way to write in a default background-img:url into this template?
<section class="page-title" <?php if($bg):?>style="background-image:url('<?php echo esc_url($bg);?>');"<?php endif;?>>
<div class="auto-container">
<h1><?php if($title) echo balanceTags($title); else wp_title('');?></h1>
<div class="bread-crumb">
<?php echo convo_get_the_breadcrumb();?>
</div>
</div>
Add this before your code:
if(empty($bg)){
$bg = '/path/to/your/default/image.jpg';
}
<section class="page-title" <?php if($bg):?>style="background-image:url('<?php echo esc_url($bg);?>')" <?php else: ?>
style="background-image:url('your URL')"
<?php endif; ?>>
Using #psdev's code, I was able to add in a default background-image if $bg was empty. Thanks!!
<section class="page-title" <?php if(empty($bg)){$bg = 'http://aqmenalt.mhsites.co.uk/wp-content/uploads/2017/06/Banner-10.png';} if($bg):?>style="background-image:url('<?php echo esc_url($bg);?>');"<?php endif;?>>
<div class="auto-container">
<h1><?php if($title) echo balanceTags($title); else wp_title('');?></h1>
<div class="bread-crumb">
<?php echo convo_get_the_breadcrumb();?>
</div>
</div>
I was trying to learn how to create a joomla template. I successfully override some modules and components on my template however I can't override the error message especially on form validation.
I would like to know where the files are located and is it possible to override? My purpose is to add some bootsrap classes and add more tags on it.
The actual generated system message is in /layouts/joomla/system/message.php
<div id="system-message-container">
<?php if (is_array($msgList) && !empty($msgList)) : ?>
<div id="system-message">
<?php foreach ($msgList as $type => $msgs) : ?>
<div class="alert alert-<?php echo $type; ?>">
<?php // This requires JS so we should add it trough JS. Progressive enhancement and stuff. ?>
<a class="close" data-dismiss="alert">×</a>
<?php if (!empty($msgs)) : ?>
<h4 class="alert-heading">
<?php echo JText::_($type); ?>
</h4>
<div>
<?php foreach ($msgs as $msg) : ?>
<div class="alert-message">
<?php echo $msg; ?>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
You can fix template CSS at /template/(your_template)/css/template.css
Or you can make new CSS with /template/(your_template)/css/my.css
and include it in the /template/(your_template)/index.php:
$doc->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/my.css');
If you need to temporary override CSS class from your CSS you can use " !important" about the overrided attribe in the CSS file.
I'm trying to do something, which I feel really dumb for, and I'm sure is very simple. However, I'm having such a difficult time trying to find any clear examples on the web. I've tried modifying divs and css, but to no avail.
Can anyone give me a clear example of how to have, for instance 2 or more form fields on the same line in Cactive form for creating a new model, as opposed to the default one on each line.
Any help would be greatly appreciated!!
I've attempted form = 'wide form'
but I get strange formatting that ends up like in the example here:
http://imgur.com/E5VVs
Suppose this is your form (taken from Yii documentation)
<?php $form = $this->beginWidget('CActiveForm', array(
'id'=>'user-form',
'enableAjaxValidation'=>true,
'enableClientValidation'=>true,
'focus'=>array($model,'firstName'),
)); ?>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'firstName'); ?>
<?php echo $form->textField($model,'firstName'); ?>
<?php echo $form->error($model,'firstName'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'lastName'); ?>
<?php echo $form->textField($model,'lastName'); ?>
<?php echo $form->error($model,'lastName'); ?>
</div>
<?php $this->endWidget(); ?>
You could use blueprint default built depending on the width of your page to split it into 2 columns like
<?php $form = $this->beginWidget('CActiveForm', array(
'id'=>'user-form',
'enableAjaxValidation'=>true,
'enableClientValidation'=>true,
'focus'=>array($model,'firstName'),
)); ?>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<div class="span-8">
<?php echo $form->labelEx($model,'firstName'); ?>
<?php echo $form->textField($model,'firstName'); ?>
<?php echo $form->error($model,'firstName'); ?>
</div>
<div class="span-8 last">
<?php echo $form->labelEx($model,'lastName'); ?>
<?php echo $form->textField($model,'lastName'); ?>
<?php echo $form->error($model,'lastName'); ?>
</div>
</div>
<?php $this->endWidget(); ?>
you can get your self familiar with blueprint css or general css rules in tons of places on the web. sorry I cant help more without seeing your code. if there is already a built in magical solution for this perhaps someone else knows it?
For the below example:
<div class="row">
<?php echo $form->labelEx($model,'firstName'); ?>
<?php echo $form->textField($model,'firstName'); ?>
<?php echo $form->error($model,'firstName'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'lastName'); ?>
<?php echo $form->textField($model,'lastName'); ?>
<?php echo $form->error($model,'lastName'); ?>
</div>
All you need to do is set change a little css
.row {
width:200px; /* or whatever you prefer */
float:left;
}
Remember to clear:left after your finished floating elements or other elements may wrap oddly.
You can also use:
.row {
width:200px; /* or whatever you prefer */
display:inline-block;
}
This does something different but may be a better option for you. Your rows will stay in the dom structure unline when floating, but it may have unintended results. Try both and see what you come up with.
Just change the CSS class to "column" instead of "row" of the div prior to ones you wish to put on the same row.
Example:
To change the following four row divs ...
<div class="row"> ... </div>
<div class="row"> ... </div>
<div class="row"> ... </div>
<div class="row"> ... </div>
into three divs that sits side-by-side, and the last div on a new row, just do the following:
<div class="column"> ... </div>
<div class="column"> ... </div>
<div class="row"> ... </div>
<div class="row"> ... </div>
Or am I completely misunderstanding the question...
I have a div that looks like this:
<div id="restinfoinn">
<div id="resthead">Purpose</div>
<div id="restcontstitle2"><?php echo $row_pages_here['purpose']; ?></div>
</div>
I want it to be omitted if the value of purpose is empty/null. How can I do this?
<?php if (!empty($row_pages_here['purpose'])) : ?>
<div id="restinfoinn">
<div id="resthead">Purpose</div>
<div id="restcontstitle2"><?php echo $row_pages_here['purpose']; ?></div>
</div>
<?php endif; ?>
But i think it would be better to print the empty div and deal with the design in CSS
This is really basic. You just need to do an IF check on top.
<?php if (!empty($row_pages_here['purpose'])) : ?>
<div id="restinfoinn">
<div id="resthead">Purpose</div>
<div id="restcontstitle2"><?php echo $row_pages_here['purpose']; ?></div>
</div>
<?php endif;?>
Have a look at alternative control syntax and empty