How to refrest the content of a page using cakephp? - cakephp

I wanna refresh the content in a page, for example like when you like a photo in facebook, you can notice the text change from like to not like and the number of likes increase or decrease.
I'm doing using a redirection to the controller, the problem is that the page go to the beginning and I don't want that. anyone know what I need to do to stay in the same part of the page and that the fields changes?

Related

Saving pagination position

I have made a pagination for a list by Bootstrap and Backbone. The list contains links for different pages. What is the best way to to "save" the pagination "page" when user goes to different page and comes back to page where the pagination is the pagination gets resetted to page one. I can't use hash because there are many bugs with window.history.back(). Are there any decisions? Or how can I use cookies?
The standard way to do this is to use routing; When you press the back button from browser you will be redirected to the last route; If you have a custom back button on the page, add on your page model last_page property. When you render the page set the route as url address.
Maybe you have problem with your application structure. BackboneJS used to write single page. So that, when you choose different page index, your page should not reload, only new data is applied to your table. You should start with this book http://addyosmani.github.io/backbone-fundamentals/

Go back to N'th "page" of a page in Angular

There is a page with thumbnails. At the bottom there is have a "Show more" button that loads more thumbnails. A user can click on a thumbnail and re-direct the application into details. When the user clicks browser's "back" I would like him to land in the same position as before. How to achieve this without complex routing?
You can achieve something like this using angular-bootstrap-lightbox and the ui-bootstrap pagination. Both are Angular and use common resources
EDIT:
What you're looking for is something along the lines of scroll-sneak, you want to save the scroll position when you redirect to another page and load the last position when you redirect back.
since I could not find any angular directive to do so, you can either
get one and wrap it around a directive, most of them use jQuery
you can make your own.
for example, you can use js to define a queue array and store it in localStorage/sessionStorage, when you redirect "push" the current page location to the queue, when you redirect back, "pop" that last stored position.
Maintain Scroll Position of large HTML page when client returns

How can I show or hide some buttons depend on the user's rights, in angularjs?

With angularjs, we usually use plain HTML to write views. Now I have a question: how can I show or hide some buttons depend on the user's rights?
For example, current page is displaying an article. If the current user is the author or the article, or administrator, then "Delete" button will be displayed.
But since the view is plain HTML, how can I control it?
I can post an request to pass some data(e.g. current user id, article id) to server to check, but if there are many buttons, I need to request many times, which is not effective.
Is there any better way to do this?
You can use the ngShow directive. I put together a little demo, but the important bit is simply:
<button ng-show="user.id==post.postedby">Delete</button>

Visualforce Custom lookup visualforce page

I was wondering if there is a way to override the native functionality of the lookup field in Salesforce and replace it with a visualforce page. The reason I'm trying to override this button is because when the user does a look up, the look up returns everybody with that name. What we want to return is a list of all the contacts by account for the contact being searched.
Here's what I'm trying to achieve:
When the user clicks the lookup button my visualforce page will launch and allow the user to see the account and all the contacts of that account.
Is this even possible? What other ways would you suggest going about this?
Here's a screen shot of what I'm trying to change:
Thanks for all your help!
It sounds really like you just need to customise the columns on the lookup to make it better suited to your needs. If you go to Setup -> Customize -> Contacts -> Search Layouts, you'll see entries for Lookup Dialogs and Lookup Phone Dialogs, there you can edit the columns displayed in the lookup windows.
If you really need a custom solution:
You can't override the lookup page itself, but you could create a new visualforce page for your account, using <apex:detail> and other similar tags to make your life simpler. Then you could include a search section underneath, where a user can enter various search terms which you put into a dynamic SOQL query and then render the results for them to choose from.
yeah its possible by javascript as i did by visual force page that will show the records of related lists and upon selection id of that record passed to parent window by jscipt. and performed same functionality ..
As far as I know - NO.
As a workaround you can use JavaScript.
What we did in our situation? We implement everything in JavaScript. We created an inputText and right on the right of this inputText we placed image with this lookup icon. On image click we create ExtJS popup window (I think you can simply create VF page and show this page in popup window). After window was closed you fill in the inputText field.
There's no out-of-the-box override for this button, last I checked, so something custom would be required. If you're set on having a popup and do not want an inline solution, I'd recommend reviewing this tutorial to get familiar with some of the issues with popups in Visualforce.
But considering what you are looking to accomplish, you could also have your account and filtered list of all contacts associated with that account appear inline on your page when the user clicks a new, custom search button. Of course that page would itself be in Visualforce (or inline Visualforce in a standard page layout) - which you may or may not want to have to code and maintain.
The AJAX Toolkit might also be a good place to start if you want to go with a custom JavaScript button placed on a standard page layout.

Drupal 7 add block of text to front page

I'm new to Drupal but I've found my way around it pretty easily. There's just one thing I haven't found out how to do, and it's so simple it has to be possible.
I created a template for the site's homepage as it will have a different layout (did it creating page--front.tpl-php). This page will display only the main menu, an image and a text of the company's mission statement. I've done everything but the mission text and I have no idea how to do just that: simply put a block of text there.
I know I can hard-code it on the HTML but I want my client to be able to change it eventually if he wants to, in a graphic way. I tried creating a content type but I can't remove the title field and some submitted info; I thought of using Views but it seems too complicated for what I need, isn't it?
The image I used is hard-coded on he HTML as I know it won't change, but maybe I should have created a view with both the image and the text? But then how would I get rid of the title field and submission info?
Can someone please suggest the best way, if possible, to do this? Perhaps I'm over-complicating.
Thank you.
The easiest way would be to create a region in your theme and then put a block into that region only on the home page.
In mytheme.info:
...
regions[front] = Front Page Text
...
In page--front.tpl.php:
echo render($page['front']);
Then in your blocks administration page create a block and assign it to the "Front Page Text" region with the content you want to output. You could also limit the block's visibility to <front> if you want to be sure, although if you don't output that region in any other template file it shouldn't make a difference.

Resources