Cakephp 3 Element file is missing - html

I have the problem that my navbar.ctp element isnt loading i only get the error message from cakephp
Element file "Element/navbar.ctp" is missing.
My code in my default layout of cakephp (because i want the navbar in all "views")
<?php
echo $this->element('navbar');
?>
and my element is in Layout/Element/navbar.ctp
So i dont unterstand why it says me that my element is missing.
Do i have anything missing?
I hope someone could help me with the problem. I dont have much information, because its not complicated per se.

I think you have the file in the wrong folder.
Check the cookbook:
Elements live in the src/Template/Element/ folder, and have the .ctp
filename extension. They are output using the element method of the
view:
echo $this->element('helpbox');
Source: https://book.cakephp.org/3/en/views.html#elements

Related

How to make a custom Archive page with Wordpress using custom post types and acf fields

I am building a child theme on GeneratePress to create a custom site for a client and am stuck on customizing the Archive pages. I've determined that it will be best to ignore the theme functionality and build the page loops from scratch. The custom archive should take the place of wp/generatepress' standard archive page and function in the same way by showing relevant posts when a taxonomy term is clicked. I need to be able to choose which html tags are used and style them with css. My issue is that I don't understand wordpress dev enough to figure out how to do this.
I have two custom post types, Research and Resources, as well as a bunch of different custom taxonomies that are applied to both or each post type. I'd like to customize the archive page (with archive templates if necessary) so it displays the appropriate Research and/or Resource files when visited.
I understand that I need to loop through all the posts, but I do not know how to grab only the relevant ones per the given archive page.
Examples of loops with example content will be the most helpful. Thank you!!
I chatted with someone on Reddit who kindly answered this question for me here.
They said:
So I wouldn't do it as a template personally (you could), I would do it through having two new files a archive-research.php & archive-resources.php.
Then if the loop is going to be the same on both pages, which I think you said it is going to be (you just want to display the posts from each custom post type), I would use a template part.
So create a new folder in your theme folder called inc or includes and name the file custom_post_loop.php (name can be anything).
Then in your archive page, call...
<?php get_template_part('inc/custom_post_loop');?>
In that file you are just wanting to write a simple post loop in there.
while ( have_posts() ) : the_post();
// Your loop code
// just so you can see this work I have called the title
the_title();
endwhile;
else : _e( 'Sorry, no posts were found.', 'textdomain' ); endif; ?>
https://developer.wordpress.org/reference/functions/have_posts/
Have a look at that link to find out more. But thats the direction to go...
If you really wanted to got the direction you have with the template, you would have to add arguments to your posts loop.
it works the same way but instead of archive.php its taxonomy.php...
However, you don't want a taxonomy-{taxonomy name}.php file for each taxonomy as that would be ridiculous unless you knew all the taxonomies haha and had really specific user cases for them...
so just create a taxonomy.php in your theme files and to make sure its working just add this code to it...
<?php get_header();>
<h1><?php the_archive_title();?></h1>
//then put your loop in from earlier...
<?php get_template_part('inc/custom_post_loop');?>
<?php get_footer();?>

HTML: Relative Link without Parameters

I have a page name index.php. It is in the folder name test. So if I call localhost/test I can see the page.
I have links in the page that pass parameters:
Link1
Link2
So the URL is localhost/test/?id=1
After that I want to link to the root page (index.php) but I don't want to use href="index.php". I want a link for root page without parameters. So when the user click the link, he/she can go to localhost/test again.
Is there any standard or something?
Try simply using a question mark:
Link1
Link without params
I allways solved this with PHP. In PHP I would have a string variable named '$APP_ROOT' and assign the path to index.php to it. Then you can use this variable to print/echo it in the HTML.
Example (not sure if syntaxt is ok):
<?php
$APP_ROOT = 'localhost/test';
?>
Link1
Link2
With a template engine this could be cleaner. The $APP_ROOT variable needs to be changed when you deploy it to the server.
BUT maybe even more easy is the HTML base tag. I dont know for sure if the base tag is good, I have never used it. Large amount of information is here: Is it recommended to use the <base> html tag?
The "../test" solved my problem.

JWPlayer in Drupal has container ID starting with Numeric Character

Following up this question on SO, I am looking to change the default DIV container name that JWplayer provides to JWPlayer Div. The problem is that it starts with a numeric and that creates loading problems.
Is there a way, I can customize this JWPlayer ID ?
This is how it looks btw,
jwplayer('141ef7fe77391234fc105767808cc0a5').setup({"file":"my_video.mp4",
"width":"838","height":"383","controlbar":"none",
"modes":[{"type":"html5"},{"type":"flash","src":"http://path/jwplayer/player.swf"}]});
While you're at it, here is a quick solution to it.
Since this is a fix for Drupal JWPlayer Module, do the following:-
Go to jw_player module folder and open theme folder.
Open jw_player.tpl.php and add the following line on top (probably where PHP declaration starts).
$html_id = "myvideo". $html_id;
It kinda does the job but I am sure you guys have better solutions than this. Please feel free to comment.
Found a better solution
Don't do upper suggestion. Paste the following code in jw_player.module instead.
Find this line $variables['html_id'] = md5(rand()); (I guess line 308) and uncomment it before pasting the following code instead.
while(1) {
$variables['html_id'] = md5(rand());
if (ctype_alpha(substr($variables['html_id'], 0, 1))) {
//echo "First Digit is Alphabet";
break;
}
}
Thanks.

Convert codeigniter code to html

I have placed a codeigniter code and i want that code in html.Pls help me to do this.
<? echo anchor('login/signup', 'Create Account');?>
Not sure why you want that code (which generates an anchor when the HTML page is rendered - look at your browser page source)
But what that CI URL helper translates to is:
Create Account
I can only assume you maybe want to add attributes to it and don't know how?
For example, you could add an ID and/or class like so:
<? echo anchor('login/signup', 'Create Account', 'id="some-id" class="some-class"');?>
Just make sure you're loading that 'helper' in your controller, or set it to autoload in the config/autoload.php file (which makes the most sense for this type of helper, as it'll likely be used site wide).
For more info on the CI URL Helper, visit here:
http://ellislab.com/codeigniter%20/user-guide/helpers/url_helper.html

making html web page

I am making a web page with html. I made a choose button that the users can select a file and upload it. I want them to be able to upload a and if the file that they chose is wrong . Is it possible to do that with html syntax what else I should add more?
Thank you,
You can use PHP to do that, make the code to upload a file and if the choice is wrong send a PHP header with you status code :
<?php header("HTTP/1.1 402 Payment Required"); ?>
you need server side code, e.g. in php you can use: http://php.net/manual/de/function.http-response-code.php