Here's what I have on the layout page:
<?php
$this->widget('zii.widgets.CBreadcrumbs', array(
'links'=>$this->breadcrumbs,
'separator'=>' > ',
'homeLink' => CHtml::link('Initial Page', Yii::app()->homeUrl)
));
?>
Here's what I have on the view:
$this->breadcrumbs=array(Yii::t('srr', 'Routes'));
Here's the folder and files structure:
views/activity/index
views/activity/route
When the user is on index he/she sees the breadcrumb like this:
Initial Page > Activity
When the user is on route he/she sees the breadcrumb like this:
Initial Page > Route
I wish to, when the user is on route page, to have a breadcrumb like this instead:
Initial Page > Activity > Route
Route is a static page, but has it's own action (just in case) on activity controller.
How can we accomplish something like this ?
Breadcrumb links are just like this:
'Label'=>'url'
So you can do this in the view:
$this->breadcrumbs=array(
'Activity'=>array('index'),
Yii::t('srr', 'Routes')
);
Related
I have a custom module which defines a custom page in Prestashop.
It consist on a template which extendes page.tpl and a front controller.
I would like to understand where shall I modify the metas for this specific page.
I see in this controller this part where the template is invoked:
$this->context->smarty->assign(array(
'link' => $this->context->link,
'category' => $this->category,
'main_category_logo' => $image_url,
'description_short' => Tools::truncateString($this->category->description, 350),
'sub_categories' => $data,
'body_classes' => array($this->php_self.'-'.$this->category->id, $this->php_self.'-'.$this->category->link_rewrite),
'search_url' => $this->context->link->getPageLink('search', null, null, null, false, null, true)
));
$this->setTemplate('module:'.$this->module->name.'/views/templates/front/category.tpl');
Is this the right place to add the metas? How this shall be done?
In PS 1.7 that's really easy modifying it in the tpl of a front controller.
{extends file='page.tpl'}
{block name='head_seo_title'}
MY META TITLE
{/block}
{block name='head_seo_description'}
MY META DESCRIPTION
{/block}
{block name='head_seo_keywords'}
MY META KEYWORDS
{/block}
And here another option from SEO & URL from the back office: How to change meta title in prestashop module?
in PrestaShop 1.7, you also can create your own getTemplateVarPage() function in your ModuleFrontController class, calling the parent and set the meta variables as you want (useful for an item page type like blog article, news, store, ...), so you don't have to put logic in your template.
public function getTemplateVarPage()
{
$page = parent::getTemplateVarPage();
$page['meta']['title'] = 'MY META TITLE';
$page['meta']['description'] = 'MY META DESCRIPTION';
$page['meta']['keywords'] = 'MY META KEYWORDS';
$page['meta']['robots'] = 'index'; // noindex, nofollow, none, ...
return $page;
}
If it's a static page like a list or a mono page, you can add the controller and set the Meta information directly in the Back Office (SEO menu).
Good luck
I have controller named GlossaryController with 2 actions indexAction and anotherAction in view i have a directory glossary and index.volt file
i want to define a route with parameters for example
http://localhost/project/glossary/another/params it should redirect me to indexAction with parameters
In your routes.php file in app/config folder add this line:
$router->add("/glossary/another/{param1}/?{param2}", array(
"controller" => "Glossary",
"action" => "another",
));
And your anotherAction method will be like:
public function anotherAction($param1, $param2 = 0) {
//some code
}
This way first param must be sent, second one is optional, you can add this way as much params as you like.
See official docs for various ways of routing:
https://olddocs.phalconphp.com/en/3.0.3/reference/routing.html
I have a list of items. When the user clicks on an item, the user will be taken to item details page.
I want to pass an object containing item details(like item's image URL) to the route. However, I don't want to expose it in the routes url.
If there were a way to do something like <a route-href="route: details; settings.bind({url: item.url})">${item.name}</a> that would be gold.
I have seen properties can be passed to a route if defined in the route configuration. However, I don't know how to change that from the template. Another way could be is to define a singleton and store the values there and inject the object to the destination route.
Is there a way to pass values to routes from view (like angular ui-routers param object)?
Okay so I figured out a way to achieve something closer to what I wanted:
Objective: Pass data to route without exposing them in the location bar.
Let's say, we have a list of users and we want to pass the username to the user's profile page without defining it as a query parameter.
In the view-model, first inject Router and then add data to the destination router:
goToUser(username) {
let userprofile = this.router.routes.find(x => x.name === 'userprofile');
userprofile.name = username;
this.router.navigateToRoute('userprofile');
}
Now when the route changes to userprofile, you can access the route settings as the second parameter of activate method:
activate(params, routeData) {
console.log(routeData.name); //user name
}
For those #Sayem's answer didn't worked, you can put any additional data (even objects) into setting property like this:
let editEmployeeRoute = this.router.routes.find(x => x.name === 'employees/edit');
editEmployeeRoute.settings.editObject = employeeToEdit;
this.router.navigateToRoute('employees/edit', {id: employeeToEdit.id});
So editObject will be delivered on the other side:
activate(params, routeConfig, navigationInstruction) {
console.log(params, routeConfig, navigationInstruction);
this.editId = params.id;
this.editObject = routeConfig.settings.editObject;
}
hopes this helps others encountering same problem as me. TG.
I have a page with a route in the form : :client_id/tarif/:tarif_name
in the corresponding HTML page, I have a <%= collection_select(.....:tarif_name...) which enables to select the name of the tarif to be shown. That works.
How do I instruct to reload the page with the new :tarif_name parameter in the url ?
I thought of using the :onchange option helper with collection_select, but although I managed to execute javascript this way, I find no example of composing and triggering the loading of a url through that option.
Thank you very much for your help
If you are able to run javascript code in the :onchange, then window.location.href = "your_url" will make the redirect.
You will also need the selected value. Your onchange will be something like
function() {
window.location.href = "your_url" + this.value
}
Only just started using MVC 4 & I am not sure how to do the following.
I have a page that displays a list of blog articles '/blog', this page also contains a select list with a list of dates, selecting a date should auto post the form to a URL like '/blog/date/20-05-2015' this URL routes to a ActionResult in a controller, which returns a list of blog articles from that date.
I dont know how to get my form to automatically post to a URL like '/blog/date/20-05-2015'
ROUTE:
routes.MapRoute(
"blogsByDates",
"blog/date/{date}",
new { controller = "Blog", action = "IndexByDate" }
);
CONTROLLER
public ActionResult IndexByDate(DateTime date)
{
var query = from c in db.Blogs
where c.PublishDate >= date
select c;
return View("Index", query.ToList());
}
VIEW (PARTIAL)
#using (Html.BeginForm())
{
<select name="ddlMonth" id="ddlMonth">
<option value="01-06-2012">June 2012</option>
<option value="01-05-2012">May 2012</option>
</select>
}
You'll have to use jQuery or something to change the ACTION attribute of your form. There's no other way to change the destination a form posts to. Though why you're using a form when you're not sending any special data to the server. Just make it a list of clickable links.