get_template_part works on one server/host, but not another - wordpress-theming

On my own server, this worked fine:
query_posts(array('post_type'=>'events', 'paged' => get_query_var('page'), 'posts_per_page' => 10, 'orderby' => 'meta_value', 'order' => 'ASC', 'meta_key' =>'details_date'));
get_template_part( 'event-loop', 'events' );
Go to launch, move it over to client's server, and it won't work. It breaks the page actually, and the sidebar and footer don't show up. No error whatsoever, just blank space. "View Source" confirms that all HTML ceases after the "get_template_part" call. The same is happening to my "News" page, which also uses "get_template_part". I even moved these files back over to my own server to confirm they worked there, and they do. When I remove the "get_template_part", my sidebar and footer suddenly appear.
Is there any kind of server configuration that might prevent get_template_part from functioning correctly?

When using get_template_part(), the second parameter is optional. All you need is the filename of your template part file without the .php extension. You also must ensure that the template part file is in the root of your Wordpress Theme folder. In your case I'm assuming your filename is 'event-loop.php'.
Try:
get_template_part('event-loop');
Or:
get_template_part('event', 'loop');

Related

Add CodeMirror to a MediaWiki page

I know how to implement CodeMirror to a regular page but I have no idea how to do it on a MediaWiki webpage. I've tried adding the "codemirror.js" file the same way I added other scripts that I am using on the page but I get the error that "CodeMirror" is not defined when it is being initialized. In the code below shows how I added my previous scripts and the "codemirror.js".
$wgResourceModules['ext.SpecialRobotExp'] = array('scripts' => array(
'module/PID.js', 'module/grid.js', 'module/saveFile.js', 'module/codemirror.js'
),
What I need is to know where to save the codemirror.js file and how to load it to the page on a MediaWiki webpage.

Dynamic URL in Laravel 5.0

I am trying to display a specific link on all the pages in my web application. The link is given below
Some text for the link!
My routes file
Route::get('home', 'HomeController#index');
Route::get('path1/path2/path3', 'SomeController#someFunction');
Route::get('my-link', 'SomeController#myLink');
While browsing the web application, when I am at mydoamin.com/home, the link address is mydomain.com/my-link, which is correct.
But when I am at the URL mydoamin.com/path1/path2/path3, the link address becomes mydoamin.com/path1/path2/my-link. Hence, after clicking the link I get 404 error as the path doesn't exist.
How do I make the link to always show mydomain.com/my-link on all the pages without hard-coding the domain name?
Note: I have put the link code Some text for the link! in a partial file; and I am including that file in all the pages.
Why you shouldn't use /my-link?
You could use My link on a site that's running on the root directory (www.domain.com/my-link). But if you're running it in a subdirectory you need to change all the url's.
That's why Laravel introduced named routes, this will automatically creates the correct url.
For example:
If you're site runs at www.domain.com/my-website/ and you need to point to /my-link you need to change all your links in your project to /my-website/....
So I suggest to use named routes.
How to use named routes
Named routes allow the convenient generation of URLs or redirects for specific routes.
And this is de code you need to use:
Route::get('home', ['as' => 'home', 'uses' => 'HomeController#index']);
Route::get('path1/path2/path3', ['as' => 'path3', 'uses' => 'SomeController#someFunction']);
Route::get('my-link', ['as' => 'my-link', 'uses' => 'SomeController#myLink']);
After that you can use:
<a href="{{ url(route('my-link')) }}">
Some text for the link!
</a>
Laravel will automatically create the correct url for the named route you want to use.
Hope this works!
More information at https://laravel.com/docs/5.2/routing#named-routes
Should be href="/my-link", / means start from root.
You may try different ways like ./my-link ,../my-link or ../../my-link to see what happend.
see link: absolute, relative, root

Link to home page renders blank

In my rails app, I have a link to the root that renders in all browsers as
<html>
<head>
<style type="text/css"></style>
</head>
<body>19</body>
</html>
Server-side I can see all assets getting passed back. For some reason the browser will not display them because if I view page source I can see ALL my markup correctly.
Now if I load or reload the page localhost:3000 normally the page and all assets are displayed correctly. If I simply refresh I get nothing.
The only time this occurs is when I click a link back to the homepage like a href="/".
The behavior does not occur if I hardcode a href="localhost:3000/" but I don't want to do this.
Rails app, Turbolinks, nowhere in code do I use the number 19, rake routes with root GET well-defined, no public/index.html. I suspect something to the degree of caching or turbolinks but I have no clue how to resolve.
Edit: Config/Routes.rb
SCRR::Application.routes.draw do
root 'home#index'
#pages
get 'about' => 'pages#about'
get 'history' => 'pages#history'
get 'links' => 'pages#links'
get 'safety' => 'pages#safety'
get 'membership' => 'pages#membership'
get 'events' => 'events#index'
get 'grand_prix' => 'grand_prix#index'
get 'newsletters' => 'newsletters#index'
end
Edit 2: Chrome Devtools Console Errors
This error is probably more relevant
Resource interpreted as Font but transferred with MIME type application/x-woff: "https://netdna.bootstrapcdn.com/font-awesome/2.0/font//fontawesome-webfont.woff".
jquery-2.1.0.js?body=1:1078
25115 : CS -> BG : FAILED closepopuptoplevel
onloadwff.js:77
From what you've posted, I don't know whether this would be a Rails issue or a browser issue.
I see you've tagged turbolinks, which could be a contributor to the issue; so let's have a look as to what the problem might be for you:
ERB
The ERB code you should use should be the following:
<%= link_to "Home", root_path %>
If you're trying to reference the "home" url directly, there may be an issue with how you're rendering the URL, hence why it won't show. You should ensure you use the path helper as described above.
This should be coupled with the correct routes:
#config/routes.rb
root "home#index"
resources :pages, path: "" do
collection do
get :about
get :history
get :links
get :safety
get :membership
get :events
get :grand_prix
get :newsletters
end
end
Assets
You mention the assets don't render when you refresh the page, this could be an issue with Turbolinks, although I'm not sure
Turbolinks basically just reloads the <body> of the page, leaving the <head> intact. Although this might sound like nothing to do with your issue, perhaps the problem is to do with the way in which Turbolinks is working with your assets
From your edit, it may appear that your assets are not loading correctly, or are at least not being shown correctly.
I hope this helps, I doubt it will give you a constructive answer

Perl Catalyst - Page not found when using href to link to page on the same site

I am creating a Catalyst application, currently I have a simple login page that also contains a 'Forgotten Password' link. It is all working perfectly, except when I click the 'Forgotten Password' link it should take me to a brand new html page that simply contains the words "Unlucky, you should have remembered it". Instead I get a 'Page not found' error.
What I am doing:
I have a Controller called Login.pm containing the following:
sub default : Private {
my ( $self, $c ) = #_;
$c->forward('login');
}
sub login : Path('/login') {
my ( $self, $c ) = #_;
$c->stash->{title} = "Login page";
$c->stash->{page} = "html";
$c->stash->{template} = "login.html";
}
All of the above works correctly and produces the login page.
In the Catalyst root/login.html file (along with all the other bits like buttons) I have the following piece of code that should allow me to link to the 'Forgotten Password' html page.
<p>Forgot Password?</p>
The root/forgotpassword.html file it is referencing contains the following:
<!DOCTYPE html>
<html>
<body>
<h1>Unlucky, you should have remembered it</h1>
</body>
</html>
However, when I click the 'Forgotten Password' link on the login page it goes to 'mydomainname/forgotpassword.html' and says 'Page not found'.
Do I need to create a Controller for the forgotpassword page? and if so what would it need to contain? Or is there something obvious I am overlooking?
I am new to Catalyst.
Finally worked out the issue, thanks to 'mikew' for referring me to the 'Serving static content' section of the cookbook on CPAN.
What the problem was:
Using the html5 code below I was referencing a simple html page that required no interaction with Catalyst to work.
<p>Forgot Password?</p>
However, as mentioned in the Cookbook and Catalyst::Plugin::Static::Simple
"By default, the following extensions are not served (that is, they will be processed by Catalyst): tmpl, tt, tt2, html, xhtml."
and
"There are some file types you may not wish to serve as static files. Most important in this category are your raw template files. By default, files with the extensions tmpl, tt, tt2, html, and xhtml will be ignored by Static::Simple in the interest of security."
To prevent the 'Page not found' error (as the html page is ignored by default) you need to do add the following to the MyApp.pm file ensuring that you remove the extension/s you do not want to be ignored (in my case html files).
MyApp->config(
static => {
ignore_extensions => [
qw/tmpl tt tt2 xhtml/
],
},
);
I believe what you want to do is make sure that file is served up statically. Look at the cookbook for making sure you are configured to serve up static files instead of sending that request through catalyst.

How do I include a CSS file with HTML email that I send from a Perl CGI script?

I am using following code to create and send email through CGI perl. The images get attached properly, but the css files do not.
my $msg = new MIME::Lite(
From => $from,
To => $to_list,
Subject => "My subject",
Type => 'text/html', # 'multipart/mixed'
Data => $body
);
$msg->attach(Type => 'multipart/mixed', Path => $DOCS_URL . "/fonts-min.css");
$msg->attach(Type => 'multipart/mixed', Path => $DOCS_URL . "/eat.css");
$msg->attach(Type => 'multipart/mixed', Path => $DOCS_URL . "/site_styles2.css");
$msg->attach(Type => 'multipart/mixed', Path => $DOCS_URL . "/calendar_layout.css");
$msg->attach(Type => 'multipart/mixed', Path => $DOCS_URL . "/errnacc.css");
$msg->attach(Type => 'image/png', Path => $DOCS_URL . "/separator.gif");
$msg->attach(Type => 'image/png', Path => $DOCS_URL . "/trans_pixel.gif");
$msg->attach(Type => 'image/png', Path => $DOCS_URL . "/itg_side.gif");
$msg->send();
The images get attached properly, but the css files are not attached at all.
Any idea what 'Type' should be used to attach CSS files?
Or is there any other problem?
I believe text/css should be OK
From my tests, many email clients simply remove all the head elements before displaying an email message. Therefore, using external style sheets isn't feasible if you have to support a wide range of email clients.
My advice is to include styling directly into the HTML, as painful as that is.
I have to say, if what you're trying to do with your script is send HTML-formatted email, even if you get the CSS files sent as attachments, it's not going to work.
The only way to do this with any confidence at all is to send HTML with all external files linked using absolute URLs. And even then it won't work the way you expect it to.
Try using inline css ...it works (see http://www.tizag.com/cssT/inline.php)
I think you already got your answer but in my opinion good way is, instead of putting html code directly, use some html based mail envelope having message and placeholders in separate html file and then parse and replace placeholders so that you can use CSS easily and i think it will be easy to maintain too.
just came across same issue. you may try this tool, http://templates.mailchimp.com/resources/inline-css/
remember to save the copy of original template in case you need to update