BOLT: Not able to set 404 page - bolt-cms

In BOLT config.yml file I have set the
notfound: index.php
So that every not found exception takes user to the homepage but for some reason it's not working for me. e.g: http://meubleshouse.com/some-invalid-url
Any idea what I am doing wrong here?

That's not how it works, since it expects either:
The name of a .twig file from your theme folder
Or you'll want to create a 'page' called something like '404 not found', and then put it in config as notfound: page/404-not-found.

Related

image exist in folder but not displaying yii2 advanced

I am using Windows 10 and trying on my local. From backend, I am able to successfully upload image in backend/web/uploads folder and on frontend I tried to access via following code in gridview.
['attribute'=>'manufacturer_logo', 'label'=>'Logo', 'format' => 'html', 'value'=>function ($searchModel, $index, $widget) { return Html::img(Url::to('#web/uploads/' . $searchModel->manufacturer_logo),['width' => '50px']); }],
When I see image path from console then path looks like
/myprojectname/backend/web/uploads/home_page_default_image.png
I also tried path with http like
http://localhost/myprojectname/backend/web/uploads/home_page_default_image.png
but image is not showing, it is present in the folder, I am not able to find out what is the mistake?
Your code looks good. So, a short checklist:
Verify that the file exist
Try the URL to the file directly on browser, the image have to appear. If not check permissions but as you are on windows, I don't think this to be the issue.
You don't need to use Url::to inside Html::img. This one knows how to interpret #web alias
Remember, you save with path but to show you need to use url. So, you need to make sure you are pointing to the same location.
And this one here is the behavior we created to forget about upload issues. https://github.com/daxslab/yii2-uploader-behavior.
When you call #web in backend it loads domain/backend/web, but when you call it in frontend - it's domain/web or domain/frontend/web (I don't know if you have some htaccess rules) so here is your problem.
Image url is with backend.
You just set path like Url::to('/backend/web/uploads/' . $searchModel->manufacturer_logo)
or use another way to concatenate backend before all.
Also you can set new alias.
In common/config/bootstrap.php add this Yii::setAlias('#backendweb', '/backend');, so your image url will be:
Url::to('#backendweb/uploads/' . $searchModel->manufacturer_logo)

Polymer build appears to exclude files in fragments

I notice my files in polymer.json/fragments are not copied over to my build/bundled folder. This causes 404 errors, how can I resolve this?
Strangely they are copied for the unbundled folder ...
Seems like this is usually because there is some error in polymer.json. For example, when trying to include a file that does not exist. Unfortunately, Polymer does not fail with an error; it succeed with weird results ...

Why does my file download link seem to work, but is unable to find the file?

I added this HTML to a page that I render via a REST call:
StringBuilder builder = new StringBuilder();
. . .
builder.Append("<p></p>");
builder.Append("<a href=\"/App_Data/MinimalSpreadsheetLight.xlsx\" download>");
builder.Append("<p></p>");
. . .
return builder.ToString();
My ASP.NET Web API project has a folder named "App_Data" which does contain a file named "MinimalSpreadsheetLight.xlsx"
The download link is indeed rendered on the page, and clicking it does appear, at first, to download the file (it has the Excel icon, and it bears the file name), but beneath that it says "Failed - No file":
Is the problem with my HTML, or the path I'm using, or file permissions, or what?
I've only tested this with Chrome, so far, BTW. IOW, it's not an IE issue.
UPDATE
I tried it with a leading squiggly, too:
builder.Append("<a href=\"~/App_Data/MinimalSpreadsheetLight.xlsx\" download=\"Spreadsheet file\">");
...yet, alas, to no avail.
UPDATE 2
I changed the pertinent line of HTML to this:
builder.Append("<a href=\"App_Data/MinimalSpreadsheetLight.xlsx\" download=\"Minimal Spreadsheet file\">");
...and it displays in the source like so (with some context):
<p>(Invoice Count excludes credits and re-delivery invoices)</p><p></p><p></p><a href="App_Data/MinimalSpreadsheetLight.xlsx" download="Minimal Spreadsheet file">
...but the link does not appear at all.
UPDATE 3
I was misled by this reference, which showed no text being added; I changed the code to this:
builder.Append("Spreadsheet file");
...(adding "Spreadsheet file" and closing out the anchor tag), and now the link appears; however, I still get the "Failed - No file" msg, and 2-clicking the "downloaded file" does nothing.
UPDATE 4
I tried two other permutations of what's seen in Update 3, namely with the forward whack reintroduced prior to "App_Data":
builder.Append("Spreadsheet file");
...and with both the squiggly prepended and the forward whack:
builder.Append("Spreadsheet file");
...but the results are the same in any of these permutations ("Failed - no file").
UPDATE 5
I also tried it without the "App_Data" at all, on the off change that is not needed:
builder.Append("Spreadsheet file");
...but the same "Failed - No file" is the result of that attempt, too.
UPDATE 6
Okay, so I tried this, too (single quotes):
builder.Append("<a href='/App_Data/MinimalSpreadsheetLight.xlsx' download='Minimal Spreadsheet file'>Spreadsheet file</a>");
...but no change. The file is there:
...so why is it not seen or accessible?
UPDATE 7
This:
string fullPath = HttpContext.Server.MapPath("~/App_Data/MinimalSpreadsheetLight.xlsx");
... (which I got from here) fails to compile with, "An object reference is required for the non-static field, method, or property 'System.Web.HttpContext.Server.get'
2-clicking the err msg highlights just "Server"
UPDATE 8
This (which I got from the same place as what I tried in Update 7):
string justDataDir = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
string url2 = string.Format("Spreadsheet file</button>", justDataDir);
builder.Append(url2);
...does nothing; clicking the link doesn't even give me a fake/failed download now...
justDataDir is:
C:\Projects\ProActWebReports\ProActWebReports\App_Data
url2 is:
Spreadsheet file</button>
UPDATE 9
I noticed on further fine-tooth-combing that url2 had a forward whack in it; I changed it so that all the whacks were back, but it made no difference to Update 8's results: clicking the link does nothing whatsoever.
If somebody solves this, it will definitely get bountified after the fact.
UPDATE 10
Maybe what I really need to do is, instead of the simple html, add some jQuery that will download the file. But the question is, can jQuery access the App_Data folder any better than raw/simple html can?
The app_data folder is used by iis and asp.net as a private area in which to put database files which can only be accessed by code running on the server.
If you try to access the folder directly via your browser you will get a permissions error.
In order to make the files available for download, move them the a folder under 'Content' (if you have an mvc site) and ensure that your web.config allows the .xlsx exention to be downloaded.
It may depend on what version of iis you are using.
Downloading Docx from IE - Setting MIME Types in IIS

SublimeCodeIntel and Symfony2 autoloading

I am trying to move from PHPStorm to Sublime Text 3 but I got stuck on the autocomplete using SublimeCodeIntel in conjunction with Symfony 2. How can I make SublimeCodeIntel to scan all the vendor/ and src/ directory of my project?
Right now whenever I'm in the controller and I'm typing something like
$response = new Response()
$response->get
I get Warning: evaluating 'Request' at GamesController.php#27: could not resolve first part of 'Request'.
First, select the Settings-Default and Settings-User options under Preferences -> Packages -> SublimeCodeIntel. Copy the full text of the Default file and paste it into the User file, which should be empty if you haven't customized the plugin at all. You can now close the Default file.
Now, in the main body of the preferences, set
"codeintel_max_recursive_dir_depth": 25,
"codeintel_scan_files_in_project": true,
Next, scroll down to the bottom to the codeintel_config array, and edit the PHP section to the following:
"PHP": {
"phpExtraPaths": ["/path/to/library/files", "/another/path"],
"codeintel_scan_files_in_project": true,
"codeintel_max_recursive_dir_depth": 25
}
Save the file, restart Sublime, and you should be all set. If for some reason it's still not working, go to your ~/.codeintel/db directory and delete the PHP directory. You may also find a similar directory in the root of your project, so if it exists go ahead and delete that one too. This forces a reindexing of your code and includes, and since it's based on your new config options everything should work as expected. Remember that reindexing can take some time, so be patient.
Good luck!

Timthumb Could not find the internal image you specified

I am using Timthumb to reisze pictures in my wordpress blog.
It's woirking fine on my local machine but when upload it on remote server Timthumb return me the following error:
Could not find the internal image you specified.
And a 400 Bad request in browser console.
How to fix this? i've been told that it might depend from server path configuration.
Timthumb version i am using is: 2.8.10
I just had that error and it was because it was looking for the file in the wrong place in the filesystem. Enable debugging and set it to level 3. Open the page where it says this error. Download the error log (same directory as the script). You'll see all the paths it tries. Output dirname(__FILE__) from just about anywhere. You'll see the real path it needs. Add it to the timthumb-config.php as
$_SERVER['DOCUMENT_ROOT'] = '/home/username/public_html';
Just as an example I had to do this (wrap in php tag). Previously it was using something with /bin/usr/htdocs in it, and that's too much detail!
Around line 850 in the getLocalImagePath funcion, add this:
$src = str_replace ( "~username/" , "" , $src );
This is optional, replace username with something else.
Another case where you are using some htaccess magic so the images are accessed like /files/2012/02 rather than /wp-content/uploads/2012/02 TimThumb would work well if it'd treat this as an external URL... But it treats it as internal and it won't find the images so set a docroot accordingly and you might need to use the replace hack mentioned previously.
I have some tweaks on .htaccess to hide the fact that I'm using Wordpress.
On timthumb 2.8.11.
After
$this->localImage = $this->getLocalImagePath($this->src);
i'v hadded this line of code
$this->src = str_replace('/file/', '/wp-content/uploads/', $this->src);
The /file/ in the normal WPway should be /wp-content/uploads/.