I am working on one concrete5 site and need to add text using placeholder in concrete5's default search block.
Edited the code like this:
<input name="query" type="text" value="<?php echo htmlentities($query, ENT_COMPAT, APP_CHARSET)?>" class="ccm-search-block-text" placeholder="Search"/>
file path is : siteroot\concrete\blocks\search\view.php.
When I use the same stuff in local Apache server, its working. But not working with other server.
Any ideas or suggestions? Thanks.
My guess is that you either changed code in the wrong part of the template (which is easy to do because the markup for the built-in blocks is extremely messy and not well-thought-out), or you have another file that is overriding the base view.
First of all, you should not edit the built-in view.php file -- instead you should override it by copying the file to SITEROOT/blocks/search/view.php. Now in that new copy of the file, make the changes you want to.
Next, try making some other changes and see if those come through -- for example, try just adding some random text to the file and see if that gets displayed. The search block combines a lot of different functionality into one place, so it's possible you're changing the file in one spot but that spot is never actually rendered (for example, the search block outputs both the search form and the search results when the form is submitted).
Also you should disable the Overrides Cache in the dashboard -- this causes a lot of problems of this nature during development.
There isn't anything in the search block itself that would change your markup, so it's probably due to caching or not having your code in the place that you think it's in.
Good luck.
Here is an idea.. Rather than trying to add to the php outside of Concrete, why not try this? I have used it a number of times with our sites that I have put together..
https://www.concrete5.org/marketplace/addons/simple-php-block/
HTH,
Kent
Related
I have a ecommerce store website running with WordPress. I'd like to include a section with a -random custormer's product review, so that every time someone access the page, there will be a different comment there.
I'm not used to PHP, but I managed to create a shortcode which takes a random comment and returns the proper HTML. It is working fine (in eddition mode, every time I insert the shortcode a different comment appears).
My issue is that when I leave the page and return, the previous one is still there. I believe that it is being caused by cache, but I wouldn't like to disable the cache for the whole page.
How you I force the shortcode run again (I don't know if it is the right way to explain) and make sure that at every access, a different comment appears?
One solution I thought is to have JS code which would do preaty much the same thing my PHP code does, using Woocommerce API to get the data. But I'm wondering if there is a simpler solution to do that, like forcing the specific section not being cached or re-run the shortcode.
Thanks!
JS can't do what PHP does here: at most it can create an AJAX-call to the backend that then runs a query for a random comment and returns it. You need to render it thereafter. It's fairly standard, but overkill for your case.
Instead, you're going to want to check whether your caching mechanism supports ESI or something else that excluded parts of your code from being cached.
I am very new to PhpStorm. I have joined a team and started working on a new feature, but found that part of my file is now without the different colors that are usually shown for PHP. It has a background, which I removed, but the text is plain white (instead of orange, yellow, etc.). I am not sure what I did or how only part of the file is like this and the rest is fine, but any help would be appreciated.
The file is PHP and has some HTML in it. Apart from this one part, everything else has the correct background and the correct coloring.
I tried invalidating the caches and restarting and that helped for a minute or two, but when I switched to something else and then back again, the problem was back. Any help would be much appreciated.
I see 3 main possible reasons:
This file is not treated as PHP by IDE (e.g. associated with just HTML/Plain Text or some another file type). For that I need to see file icon (ideally whole IDE window, just in case).
You have accidentally injected another language somewhere in the file, so that part is now treated as plain text instead of PHP. For that I need to see the screenshot of Settings/Preferences | Editor | Language Injections -- I'm interested in "IDE" in "Project" entries only (for the "Scope" column).
Some plugin interference. For that you would need to provide much more info.
Based on your screenshots, it's definitely wrong Language Injection here. Please delete those 2 injection rules (they do not make any sense to me), it should go back to normal. If unsure: disable them first, check how it goes, if all good -- delete.
You have injected XML language inside the <div> tag ... so no more PHP as it all treated as plain text now (except the HTML tags, since they work similar to XML).
I'm trying to make a really simple website with multiple pages. I've been coding in HTML for a while now, but just started to experiment with PHP.
My page setup goes like this:
Rootfolder/settings/language -- In there, I just put a index.php
Rootfolder/settings/Privacy -- In there, I also just put a index.php
In this particular case, I could indeed use rename the files to language.php/Privacy.php to reduce space. But that is still not what I'm expecting from a lightweight website.
In order to make it easier for myself, I use include_once to include the header, meta data (I know it's not smart, because of SEO reasons), footers and other stuff that is very general and has to be the same across the whole website. But here is the thing; I really think that this method is way to complicated. Every time I need a new file, I just have to duplicate the page that includes the include_once files, and then change the content of it. Same goes for the titles.
So, what I'm looking for is a page setup like this (1) :
Rootfolder/Pages/index.php -- Inside that index.php, the content has to change dynamically. The visitors still have to go to: https://domain.tld/settings/language but the server has to decode it to the setup from (1) and change the content to the original content of Rootfolder/settings/language/index.php.
In the past, I've downloaded some PHP scripts, which all included title setups like: <title> $title - $SiteName </title> (or something like that) - So it must be possible to change content dynamically.
The problem is... I really don't know where to start. Does anyone has good/lightweight solution for this?
I have a site complete with CMS etc all working under one domain name. It turns out for legal reasons one page on this site has to sit on a different domain name. The page is hooked into the same CMS as the rest of the site (built using codeigniter). I don't want to have to do another installation just for this page.
Is there any simple way to display just this page under a different domain name without taking it out of the current application?
Thanks a lot
You should look at either (in order):
an include()with correct php.ini configuration
a file_get_content() and printing the variable into your page
an <iframe src="yoururl"> wich would be the easy peasy but unsafe way
using the on-purprose curllibrary
using fopen() wich theorically allows distant files to be opened, but based on my experience, it's not that reliable
Look at this site, it seems rather exhaustive regarding your problem.
Try including the file
<?php include 'http://www.domain.com/url/to/file/page.html' ?>
I think what you need here is a symlink, which is something I don't know too much about. My understanding is that the path displayed to the user does not in fact have to have anything to do with where the file is actually stored, meaning you can set this up to have a completely different URL while keeping it as part of your original application.
A simpler thing is doing a redirect...it's one line of code in your .htaccess file and you're good to go.
include is a possible solution depending on the format of the remote page (ie, this won't work very well if the remote page has a full DOM structure, and you're trying to include the remote page within the DOM structure of your CMS page), however more information about that remote page would be needed to help determine if include() alone would be enough.
Regardless, if include() does, work, you must make sure allow_url_include in php.ini is enabled, as by default script execution will terminate when encoutering a remote URL include statement.
I have a client who wants me to do CSS coding only, but doesn't want to give me the php files.
Right now, I just have access to the live website (with no CSS).
It is entirely made with tables and I want to use divs instead
I'm not sure if it is possible to do the coding
I thought about copying and pasting the generated HTML code from each page
Will this cause possible problems with the end result?
Yes, this will cause huge problems: you'll do an awesome job, client will have trouble integrating it with their site, client will abandon your awesome work.
IMO, you should let the client know that you'll do the best you can with what they have given you, but you would be able to save them a lot of work and do a better job if you could have access to the source code.
If you know that you can't make the client happy with what they have given you, though, it would be doing everyone a disservice for you to try.
If you absolutely can't convince them to give you access to the source, then this client sounds stupid:
He has a layout which is table based.
He wants you to magically make it look better with CSS, without having access to the source.
"#Phoenix I don't see any classes or IDs." - there are no classes or ids to hook into.
You might be able to do it if you used some CSS3 selectors to, for example, select the 3rd td inside a td inside the 2nd table to apply styles to ;)
But, that won't help if you have to support older browsers, which makes this impossible at the moment without doing something differently.
I don't have full knowledge of your situation, but here's what I would probably do (if I couldn't convince them to give me access to the source):
Open the live site.
Copy the HTML source code.
Paste it into a new local file.
Add this into the <head> section: <base href="http://the-clients-site.com/" />.
This will let all the assets on the page load from the client's actual site.
Now, you have something to work with.
You have to keep track of ALL changes you make to the file.
The first change should be adding your own blank style tag.
Then, you can add id and class to whichever elements you feel need it.
You should try to avoid moving around elements, unless it's absolutely required. Those changes are a whole lot harder to explain to someone. I know from experience.
You should be able to style the page properly now.
Then, you deliver the completed page, and the documented list of changes you had to make to the HTML (add id, here add class there).
The client should then be able to integrate the changes into his site.
Well, at a bare minimum they'll need to modify ther PHP to reference your CSS. More importantly, you need to be able to hook your CS up to elements - Do tables/rows/etc. have Ids or classes attached?
If they are clever and have some good separation between code and presentation (using a templating engine or similar) then you can probably just edit the template / css.
If they won't let you edit the PHP and you come up with a new awesome layout, they will have a nightmare job trying to integrate it and probably won't bother.
I don't see the problem. You can style tables just as easily as divs. You don't have to know how the wall is built to know how to paint it, which is pretty much all you've been hired to do. Only problem I could see would be if they haven't added any classes or ids to the elements yet. After all, what the browser/client sees is the only thing that needs styling, and since you can see everything that the browser sees, you can see everything that needs styling.
If they have added classes/ids, then just take a copy of a page and style it in a testing area, and then once it looks nice, you take a copy of another page and make sure it looks nice with it too, add to the CSS if there are any new unstyled elements that didn't exist on the first page, once it looks nice, then move on to another page, and another repeating the process until you are satisfied that it appears that every page within reason would look nice with it.
If they haven't added classes/ids, tell them they need to in some capacity before you can work on it, perhaps provide some guidance on the issue.
I'm actually doing this right now for SO.
I'm working on a userscript that provides an alternate "clean" stylesheet for the StackExchange network. I have no access to the SO engine. I am using the Chrome Inspector to look at how the elements are set up. I recommend the same. (Although it is a little different, since I'm modifying the original CSS file.)
You can easily identify what you want to style with the Inspector and then work from there. I would suggest that you ask your client for a list of classes and IDs though. (I got that in the form of an existing stylesheet, you can go about it in a different way, if that suits you and your client.)