i am working on social network website where user can navigate to the album view page in many ways.
for example.
myprofile>> Gallery index page >> Album view page.
myprofile>> Gallery details page >> Album view page.
In first case back button should go to gallery index page and In second case it should go to Gallery details page.
Is there any way to add link to back button path dynamically in cakephp?
You could try using a breadcrumb-like session array. With every view you can pop a path onto the stack, and access the stack in the view (via the Session Helper) and construct the back button that way.
The stack could be as simple as a single parameter, or an array of controller, action and parameter variables to construct the path, depending on how much detail you need.
Edit: You could also use Neil Crookes' History Component: https://github.com/neilcrookes/cakephp-bits/blob/master/history_component/controllers/components/history.php
Use the breadcrump methods in the Html helper.
In your layout:
echo $this->Html->getCrumbs(' > ','Home');
In your view:
$this->Html->addCrumb('Users', '/users');
$this->Html->addCrumb('Add User', '/users/add');
In each of your views, you can add in a new crumb, or the chain of crumbs to be able to see a history of your actions.
More here: http://book.cakephp.org/view/1653/Creating-breadcrumb-trails-with-HtmlHelper
Related
I have two vf pages, say vf1 and vf2, which have standard controller for same object say Leads. Now i want to show vf1 page for edit button for any profile1 and and vf2 page for profile2 on edit button.
Tried to see any option in Profile menu, but not able to find anything for page assignment for list/edit/create/...etc. for an object.
There is no such feature in Salesforce to allow visualforce page assignment per profile.
I would recommend below
1.Create a hirerachy custom setting to store the mapping between the vf page and the profile .
2.Write a vf that will be assigned for all profiles but on action (called upon where page loads) it will look into the hirerachy custom settings map and takes the user to right visualforce page .You can pass along page parameters as query parameters .
Suppose I've 2 controllers - C1 and C2. I do a navigator.pushPage from v1.html to v2.html. And then I do a navigator.popPage on v2.html. But the popPage doesn't reload the controller C1. I'm trying to figure out a way to reload the controller, but have not been able to do that. I tried with popPage({refresh:true}) also, but that didn't help either. Here's the codepen: http://codepen.io/rohit_jain/pen/eNbyEm.
Is there any way I can achieve what I want?
Here's the real example:
On v1.html, I'm displaying the Cart details - total_cart_items or total_price. There I've a button to move to v2.html, where I display Cart contents. On v2.html, the person can reset the cart, and then go back to page v1.html. Now, I want the reset cart action to change total_cart_items and total_price on v1.html. But that's not happening.
You can achieve it using nav.resetToPage(page, options) function, which clears the page stack and add the specified page to the new stack. The options parameter corresponds to the navigator.pushPage API.
I have an ionic app that has a search template that has a form where you can query posts by keyword. I also have a service that returns the post(s) as a list on another view. All that is working well.
My search controller upon submitting the search form uses:
$state.go('app.search.results', {'searchId': hash});
so that I can have a unique url for that search. I needed this unique url to implement 'back' functionality so that if a user clicks on one of the posts in the list, after viewing the post if they decide to click back, they would get to see the results of the search still (by default they would be returned to the search form without any results anymore).
To allow for a back to search results I implemented a custom back button function and put it on the ionic back button element like this:
<ion-nav-back-button ng-click="goBack()">
and then setup a the custom function:
$scope.goBack = function() {
$window.history.back();
}
All of this works well, I can go back to search results and see them, essentially very much like normal browser back functionality.
Problem for me is that when I have gone all the way 'back' via the back button, my initial state contains the 'Back' button and clicking it does not go anywhere and the 'Back' button still shows. Ionic does pretty good about hiding the back button when it shouldn't be there but in this case not so. Any ideas for how to check when history is exhausted and hiding the back button conditionally would be appreciated.
EDIT:
Here is a jsFiddle ; Note: open fiddle in a new, separate tab to see back button issue. FYI Search is in the menu.
One of the few qualms I have with Ionic is their "smart" navigation. I have run into a lot of problems with this myself. My solution was to create a back button of my own, this back button stores previous states and their params so you can go back and not lose search results for example with your scenario.
This component gives you both a back button and breadcrumbs to use (or you can just use back button)
It is open source and feel free to use it!
jscBreadcrumbs
Strange Milk - Breadcrumbs Post
Here is your jsFiddle with the jscBreadcrumbs implemented and working:
jsFiddle
jscbreadcrumbs
You use $window.history.back(), I think you should use $ionicHistory.goBack(); instead. It can control the history and view and state in the ionic way.
I'm currently working on a single-page scrollable website (5 pages displaying as a single page) using CakePHP. I have worked on each controller action and everything runs well. I have one layout for the entire app and a view for each action. My challenge is finding a way to load the view of each action without reloading the page inside the layout. Should I just put all the view content inside the layout (without echoing $content_for_layout) or could there be a better way to do it?
Considering the div you want to update has the id #content:
$.ajax({
url:"http://yourdomain.com/controller/action",
context:document.body,
dataType:"html",
data:{id:123}, // in case you need to pass some params
success:function(data){
$("#content").html(data);
}
})
The action must return the HTML you want to display inside that div. If you want to have each pags loaded in different div's, you will have to create one div for each page and call AJAX for each one.
When the page is loaded for the first time, you can just pull the data for whatever default action you defined. Then, when you want to change the content, just call AJAX.
I'm trying to learn CakePHP by building a simple CMS app, it was going well but as I'm adding more, I'm getting a bit confused by the MVC structure.
In addition to my Posts, I have created a simple model for 'Content Blocks' (basically an admin editable title and content field) that I want to display as elements within other pages of my site.
To help explain:
My Posts controller has an index action that lists out all of the blog posts. In the view for that action I also want to pull a specific 'content block' from the database and display it at the top of the page.
Another example would be an admin-editable 'about' blurb that appears in the footer of every page.
Lastly, in a similar fashion to the Wordpress text widget or Magento static block, I'd like to prevent 'content blocks' being directly accessible (i.e. domain.com/content_blocks/view/id)
What is the ideal way to achieve this whilst staying true to CakePHP and MVC convention?
I've had several stabs at it (such as using requestAction in an element) but have only succeeded in getting more confused.
The way I would do it is as you suggested with a request action inside an element because that won't be directly accessible through the URL. So you would create a view inside the elements folder:
app/View/Elements/block.ctp:
<?php $sidebar = $this->requestAction(array(
'controller' => 'ContentBlocks',
'action'=> 'viewBlock',
'yourtitle'
));
// layout your block here
?>
app/Controller/ContentBlocksController.php
public function viewBlock($title) {
return $this->ContentBlock->findByTitle($title);
}
Then you can see this post for how to do caching with the element and requestAction: http://mark-story.com/posts/view/how-using-requestaction-increased-performance-on-my-site
Also, you might want to checkout Croogo, which has a lot of the functionality you are looking for and more already built in: http://croogo.org/