I'm making internet ordering site on Yii2 framework. Now I have page for restaurant page with products, where I can order specified product (can see on screen). How can I implement dynamic success flash image after ordering the product, that will appear on top of page and then fade out? I don't want for page to reload.
In your layout view file add (on top of your content):
<?=yii\bootstrap\Alert::widget([
'options' => [
'class' => 'alert-info',
],
'body' => Yii::$app->getSession()->getFlash('success'),
]);?>
In your controller
public function actionOrder()
{
....
//After order is made
Yii::$app->getSession()->addFlash('success', 'Your Order Has been made successfuly...');
//redirect
...
}
Related
I'm using yii2-fullcalendar widget and I used thiagotalma's post on github as a guide for the installation of the calendar widget. Below is the code that I've used to display the calendar on the page:
<?= \talma\widgets\FullCalendar::widget([
'googleCalendar' => true, // If the plugin displays a Google Calendar. Default false
'loading' => 'Carregando...', // Text for loading alert. Default 'Loading...'
'config' => [
// put your options and callbacks here
// see http://arshaw.com/fullcalendar/docs/
'lang' => 'en-ca', // optional, if empty get app language
],
]); ?>
and the above code displays the calendar on the web page. Now, I want to display the events from database but I don't have any idea how to do it. Can anyone help me regarding this matter? Thanks in advance.
You might want to look into my calendar view widget, looks like it's bang on. Takes data from your model and puts them into a responsive calendar.
I am the author btw. Should be simple enough if you read through the readme, it's step by step.
I want to display a loading image when I click on a sorting link of a listing record. Before, I used the complete property of Paginator. This works well if the table has more than one record.
My code is as follows:
<?php
$this->Paginator->options(array(
'update' => '#ourCompany-part',
'evalScripts' => true,
'before' => $this->Js->get('#loading')->
effect('fadeIn', array('buffer' => false)),
'complete' => $this->Js->get('#loading')->
effect('fadeOut', array('buffer' => false)),
));
?>
When the table has one record and we click on the sorting link of the paginator, it doesn't display the loading image. If the table has no records, then the index page is not loaded. How could I solve this?
Personally i don't like JsHelper i wrote jquery pugins or small function in my view. So check that the javascript looks like where you see 1 record or no record, it seems that helper not render javascitpt.
I am creating multiple CodeIgniter views that could possibly be placed in any order by a controller. One of these views is a table of contents that I want to display the correct order of the views as they appear in the page. Is it possible to detect which order the views appear in and then change, add or remove elements from the table of contents?
CodeIgniter won't be able to help you with it cause it renders the view instantly when you call $this->load->view(...) (see the relevant code for view loading in the core Loader class).
You'll have to do your own logic for that, there's nothing stopping you from creating an array with information about the views you need to load, and load your table of contents view beforehand:
$views = array('page1.php' => 'Page 1', 'page2.php' => 'Page 2');
$this->load->view('table_of_contents.php', $views);
foreach($views as $view => $title){
$this->load->view($view);
}
I saw the following answer to the post Where are Magento static CMS blocks stored? regarding programatically using PHP generating cms/blocks in Magento.
I changed the code to the following
$newBlock = Mage::getModel('cms/page')
->setTitle('Test CMS Page Title')
->setContent('Hello I\'m a new cms page.')
->setIdentifier('this-is-the-page-url')
->setIsActive(true)
->save();
... and it works. I see a new page show up in the CMS Pages area in the backend.
What I need to add to this is the ability to set the content of the other fields in the CMS/Page. Namely:
Layout (trying to set to 1 column)
meta keyword
meta description
fields. These fields are blank currently. I so far haven't been able to figure this part out.
Thanks,
here you go:
$cmsPageData = array(
'title' => 'Test CMS Page Title',
'root_template' => 'one_column',
'meta_keywords' => 'meta,keywords',
'meta_description' => 'meta description',
'identifier' => 'this-is-the-page-url',
'content_heading' => 'content heading',
'stores' => array(0),//available for all store views
'content' => "Hello I'm a new cms page."
);
Mage::getModel('cms/page')->setData($cmsPageData)->save();
The keys of the array are the name of the fields of the cms_page table (check the db). And to know the value, I manually create the cms page I want and then see the value for this entry in the db.
I have a default user registration form that cannot change. However my boss wants a second registration form that is laid out differently than the first. I am new to Drupal so some explanation would be great.
Thank you in advance
If you create a custom module you can define a path for the second menu item using hook_menu().
function user_menu() {
$items['user/custom_register'] = array(
'title' => 'Create new account',
'page callback' => 'drupal_get_form',
'page arguments' => array('user_register'),
'access callback' => 'user_register_access',
'type' => MENU_LOCAL_TASK,
'file' => 'user.pages.inc',
);
return $items;
}
Of course this will not look any different to your exsisting form, it will just be a different path.
To customize the form you have a coulpe of options, you could use hook_form_alter() and check the path. Or you could change the page arguments argument above to something which called user_register and customizes the output.
Let me save you some time, as I just solved this on a few sites. Check out the login forms here:
http://www.dogfish.com/user
http://www.inclind.com/user
This is the basic user login form. I am overriding it by telling Drupal to use a custom tpl file to load this page, and in the TPL, I am added additional elements and adding to style.css.
There is a write up on how to do that here:
http://www.lullabot.com/articles/hacking-phptemplate
Halfway down it shows you how to work with template.php to define new tpl pages for specific paths.
What you want to do is tell it when 'user' or 'user/register' is loaded, use a tpl file (you can name it). Then, you can work with the preprocessor functions and add to the page, like change the into words at the top, or remove certain form elements. The benefit is you can add all you want to the user registration form through the core Profile module or other modules, and they will still be presented here.
It will save you a lot of time this way instead of try to reinvent the user login process with your own module (I've tried that too).