I have never worked with CakePHP before and need to add a button that'll take a user back to the top of a page. My question is how can this be done for multiple, but not all of pages, using the framework?
I couldn't figure it out and need a quick solution to this. Any help is appreciated!
Many ways to go about this one. Simplest is edit your default.ctp (or whichever) layout with a simple condition:
<?php if (!empty($backToTop)) : ?>
<!-- html & JS back to top code here-->
<?php endif; ?>
Then in the Controller Actions that you want the back to top button to display:
$this->set('backToTop',true);
If there are only a few exceptions to not having the 'back to top' script, then you may want to have the condition to exclude the code rather
Create a helper or a method in a generic utility helper for your app that renders the button or use an element that you can include where you need it.
If you want to call it on every page put your helper or element call in your layout file(s).
In the case you need an exception on a certain page you could put that logic in the helper method as well, or the element, and check if the request object attached to the view matches your desired controller and action.
Official Documentation:
Elements
Helpers
Layouts
Related
I am just starting to learn HTML. I am trying to understand if it is possible to only have one element in the mainpage that can be use on every other pages instead of rewriting it onto every other single html file?
Thank you.
What you are talking about is called a component. A component is a reusable piece of small elements that you can use anywhere in your html. You can do it in two ways:
Server side: Make a function where you store that specific component.
Dynamic template: Use something like VueJS,ReactJS or AngulerJS to create and use a component where ever you like it. You can also use JS too. But I suggest VueJS,ReactJS or AngulerJS.
Wanting to add a div element if a class is present on the page.
This is for IPS forum software. Reached out to them about this and their response was that they would charge for a custom theme design. Would rather do this myself if possible (bit too expensive otherwise).
I want to display a specific div for the "compose new private message" modal popup without displaying it on all other modal popups. Can't use body page controllers so I'm guessing my only option, other than having the PM modal inherit from a new template, would be to try and display a div if a certain class exists.
Templates are stored in the database for IPB. You can utilize the Admin system to go in and edit the templates. There is an extensive series of menus that give you access to individual template code, for example, under Messenger, there is sendNewPersonalTopicForm, PMQuickForm, and sendReplyForm.
It should be relatively easy to go into those templates, find the markup you want and add a container div where appropriate.
For example, for a 3.x board, you find something like this:
<div id='message_compose' class='post_form'>
<form id='msgForm' style='display:block'
action="{parse url="module=messaging§ion=send&do=send" base="publicWithApp"}" method="post" enctype='multipart/form-data'>
This seems fairly simple code to alter.
I would recommend a Plugin with a theme hook. You can put your logic in the php file and assign your hook to show up exactly where you want it.
I've an issue after clicking in repeater list item, I get two items in the detail page instead of one element.
This repeater is for Booking elements and I've added the follow transformation: "Transformation" and "Selected item transformation".
The "Selected item transformation" is applied but I get two elements in the page after apply this transformation.
I tried to add a data list and instead of to get two elements after clicking on an element I get four.
I'm new in Kentico maybe it is a configuration issue.
Below I detail the configuration for the repeater web part:
Content/Path:/Events/%
Content filter/Page types: CMS.BookingEvent
Content filter/Category name: {%SiteContext.CurrentCategory.CategoryName#%}
Do you have any idea about what can be the problem?
If you need more information please let me know and I'll send you.
You can check following below things
Does the listed page & detail page uses same page template (is it inherited)?
Need to check Selected item transformation, is it setup right?.
For testing you can remove category filter and then check.
Make sure are you using <%# GetDocumentUrl() %> in list page Transformation
Thanks
Does the listed page uses same page template (is it inherited)? Do you have just one repeater on that page?
The selected item transformation renders on target page (detail of listed page) but the page needs to use same page template (or inherit the one that is on parent page listing page)
Alternatively, don't specify selected transformation and make the repeater on target page to display just its properties.
Check list and details pages. In your case details page should inherit template from list page.
Your repeater is responsible for showing list and details, so make sure there is no extra web part (another repeater or any other viewer) that shows details only.
Also try to check Hide on child pages setting in your repeater - this will help you to figure out if repeated renders 2 details (in case no details shows now) or there is another web part for details (in case only one item details appear now).
This page is using the selected item transformation correct? And this happens when you are navigating to the event page (/Event/CustomEvent1)?
Does this happen for every event? Does the event page url have any special characters in it? I have had an issue before if the page has an _ in the name and url, it will break the repeater. This was fixed in a hotfix in K9.
If you are still running with this issue, I'd suggest to remove SelectedItemTransformation and display detailed content on specific document i.e. /Event/CustomEvent1. You can use either repeater for read current document only and set detailed Transformation in "Transformation" property itself DON't use "SelectedItemTransformation" in this case.
Thanks so much for all the answers, they were pretty useful for me.
The problem was related with the inherited template. In my "Listed page" on template tab I chose the option "Clone template as ad-hoc". I've checked in the detail pages that the template option was in "Inherit from parent".
I realized too that in the root template which I've used in the "Listed page" there were a repeater, then I removed it and the problem was fixed.
Thanks so much again.
Kind regards,
Max
I have a little problem with Polymer.. but i have no idea for fix it...
when i go to my website:
http://toi-meme-tu-c.hol.es/polymer-tutorial-master/team/
and i click on the "i" for information (Case Scaroboy) ALL the drawer-panel refresh... how fix-it without javascript?
I have tried to include the drawer-panel into a php page but it's not an issue...
So I asked here, because im a begineer with Polymer...
thanks, Scaroboy
It must use Javascript i think because no core element so far build to replace the content directly. To load new content inside the main panel you will need ajax request which you can use core-ajax element (on v0.5) or iron-ajax element (on v0.8) but you will need to write Javascript function to handle the ajax response.
Or you can create your own element wrap ajax element with replace content inside container that you can pass through attribute.
My problem is i need to execute multiple times one controller, but i need to control that action. How can i add or remove an ng-controller from html tag. For example i have controller with name view and i need an <div ng-controller="view"> but i need a method to toggle it to <div>. On toggle would be better to delete the controller that took place, but i think angular do that automatically Any idea, perhaps something with directives?
You should use a directive instead of a controller. Controllers are not meant to be set and removed like this, the only way to do so would be to recompile the HTML each time which would bring more problems than it solves.
In short, this is an XY problem, please try to step back and formulate what problem exactly you are trying to resolve.