Joomla Error Message File Directory - php

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.

Related

How to make and if else / conditional division in cakephp

How to make a condition in CakePHP?
In WordPress I can only make it using
<?php if(is_page('1')){ ?>
<section id="flash-area">
<div class="flash oswald">
.....................
</div>
</section>
<?php }else {?>
//i will removed this div
<?php } ?>
Since Wordpress and CakePHP are both build with PHP you can just use plain PHP for this. In your Template file (e.g. src/Template/Pages/home.ctp) do:
<?php if ($condition) { ?>
<section id="flash-area">
<div class="flash oswald">
.....................
</div>
</section>
<?php } else { ?>
<div>Another div</div>
<?php } ?>
You can also use alternative control structures for cleaner code:
<?php if ($condition): ?>
<section id="flash-area">
<div class="flash oswald">
.....................
</div>
</section>
<?php endif; ?>
Since you didn't wrote, which condition you want to test, I assume you want to check if you're on a specific (static) page of the PagesController. Your Condition would just look like:
<?php if ($page == 'home'): ?>
You can set the conditional variables in a Controller.

PHP wordpress template - add default image if none selected

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>

Add tabs and fields to custom joomla component

How can i add more tabs and fields to a joomla component in backend,
-Tried editing the view xml file adding more fieldsets, no success
-Tried editing the edit file in view admin component, no success,
In other words i want to achieve this, just like the image
Any help?
You have to set it to the view template admin\views\*view_name\tmpl\*template_name.php.
The structure that you have to use is:
<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'general')); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'general', JText::_('COM_COMPONENT_NAME_TAB_1_NAME', true)); ?>
...
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'advanced', JText::_('COM_COMPONENT_NAME_TAB_2_NAME', true)); ?>
...
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
You could also check core components to get more examples.
As for the contents of each tab, you could restrict the loop to get the fields of one fieldset only using:
<?php foreach ($this->form->getFieldset("general") as $field): ?>
<div class="control-group">
<div class="control-label"><?php echo $field->label; ?></div>
<div class="controls"><?php echo $field->input; ?></div>
</div>
<?php endforeach; ?>

add/call widget in default.tpl layout socialengine

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>

Creating widget as an extension in Yii

I am very new to YII and its extensions... i am trying to create the basic login widget as an extension so that i can reuse it....
the following thinks i have done.
Create a widget view in extensions/widget/login/views/hloginForm.php with this codes
<?php echo CHtml::beginForm($this->url, 'post', $this->htmlOptions); ?>
<div class="form header">
<table>
<tr>
<td>
<div class="row">
<?php echo $form->labelEx($model,'username'); ?>
<?php echo $form->textField($model,'username',array('class'=>'txt')); ?>
<?php echo $form->error($model,'username'); ?>
</div>
<div class="row rememberMe">
<?php echo $form->checkBox($model,'rememberMe'); ?>
<?php echo $form->label($model,'rememberMe',array('class'=>'dull')); ?>
<?php echo $form->error($model,'rememberMe'); ?>
</div>
</td>
<td>
<div class="row">
<?php echo $form->labelEx($model,'password'); ?>
<?php echo $form->passwordField($model,'password',array('class'=>'txt')); ?>
<?php echo $form->error($model,'password'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'Forget Password?',array('class'=>'dull')); ?>
</div>
</td>
<td>
<div class="row"> </div>
<div class="row">
<?php echo CHtml::submitButton('Login',array('class'=>'logbtn')); ?>
</div>
</td>
</tr>
</table>
and created a Login.php in main widget folder
(that is : application/extensions/widget/login/login.php) with the code like :
<?php
class Login extends CWidget
{
public function run()
{
$this->render('hloginForm');
}
}
?>
and made all extensions as autoload in config/main.php
as
'import'=>array(
...
'application.extensions.*',
),
then try to use it in my webpage view file as
widget('Login'); ?>
this throw me this error
Quote
include(Login.php) [function.include]: failed to open >stream: No such file or directory
Tell me whats Wrong??? What should i do to get my Widget in my page.
and once i tried this
$this->widget('application.extensions.widget.login.Login', array());
i got this error
Quote
Alias "application.extensions.widget.login.Login" is invalid. Make sure it points to an >existing PHP file and the file is readable.
Changing the Access permission for the extension folder fixes the problem. After that it works fine as expected.

Categories