In sample HTML DOM, how can I write code to add included statements for code? I tried:
<?php $htmlh.='
<?php include('../language/common.php'); ?>'
?>
But I’m getting errors. What did I miss?
How can I write correct code under HTML DOM?
Related
In forum i see this is not yii2 standard <?= $var ?> .
Yii2 standard code is <?= Html::encode($var) ?>.
Anyone know use of Yii2 html helper class?
The content of <?= $var ?> , tipically is not encoded automatically by yii2 so the values of the $var will be HTML-encoded using
Html::encode($var).
For a useful guide about HtmlHelpers you can see this doc
http://www.yiiframework.com/doc-2.0/guide-helper-html.html
and this ref ..
http://www.yiiframework.com/doc-2.0/yii-helpers-html.html
http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html
Yii2 provide a useful set of Html helpers for a easy code manipulation
l
Let's say I have a element in foo.html. How can I import and embed it in another HTML file?
Have you tried using jQuery .load ?
So in another.html you would have:
<div id="place-to-embed-element"></div>
<script>
$( "#place-to-embed-element" ).load( "foo.html #imported-id" );
</script>
Hope this helps!
Okay ... that sounds odd. What do you mean by "importing"? HTML is a mark-up language, not a "real" programming language like PHP etc., so this functionality is, of course, not given by default. You could start to write PHP or juse JavaScript ... or just explain your question more detailed ;)
(Or just copy your html segment into the other file ]:-> )
maybe use php...
rename your file from 'file.html' to 'file.php' and copy this into it:
<?php
include("foo.html");
?>
I'm using the multiEdit plugin to create some content regions on a template.
One of those region is for some photos that are going to be using jQuery cycle to rotate through the images.
But, as usual, Wordpress (or the editor rather) is wrapping all of the images in a <p> tag.
I've used the functions hack from CSS-Tricks to remove the <p> tags from the content:
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'filter_ptags_on_images');
But, from what I can tell, it only looks for the_content and not for anything else.
Multiedit uses this: <?php multieditDisplay('name_of_region'); ?> to display the content block in the template.
So, I tried to change the function to this:
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('multieditDisplay', 'filter_ptags_on_images');
But no such luck.
So, I'm not so sure if I'm missing something or just going about it the wrong way.
Ok, well I found a workaround.
I did a write up about it here:
http://ultraloveninja.roon.io/filtering-paragraph-tags-with-the-wordpress-multiedit-plugin
Instead of placing multiEdit fields in your template like this example
<?php multieditDisplay('Top'); ?>
You could prevent the auto print by passing true as the second parameter like this
<?php echo multieditDisplay('Top', true); ?>
So if you want to strip ALL tags from the output, then try this
<?php echo strip_tags(multieditDisplay('Top', true)); ?>
If you want to include certain tags then provide a list of tags to include and pass it as a parameter to strip_tags like this
<?php echo strip_tags(multieditDisplay('Top', true), '<p><a>'); ?>
I am working in a webpage where client scripting is not allowed. This webpage uses a very huge verbose tag in the shape of:
<embed src="X" flashvars="Y"/>
It is part of a tmeplate, so it will be used in lots of pages, so I have to change the hardcoded params in an easy way for all them.
I am wondering if there is a way to do something like this in HTML:
<var name="X" content="foo">
<var name="Y" content ="bar">
<embed src="<X/>" flashvars="<Y/>"/>
So the last part would not be changed in template and all child inherited pages
Thank you!
HTML alone cannot do this. HTML is a markup language, not a programming language. It doesn't even have variables.
You need server-side coding for this. PHP is the most popular, though there are numerous others available. Then you could do this:
<?php
$x = 'something';
$y = 'somethingElse';
?>
<embed src="<?php echo $x; ?>" flashvars="<?php echo $y; ?>">
No it is not possible. HTML is static.
If you cannot use a clientside script have you thought about a serverside script?
Not through HTML directly.
You could use JavaScript to inject the values, but HTML itself does not store variables.
I am just validating my webpage and working through the errors. the scenario I have is that I have the structure where I import a header file, through <?php include ('header.php') ?> and also with my navigation file. Now in terms of seeing it in the browser this works, but when I validate with XHMTL1.1 strict it comes up with the error.
So I have an index.php which imports both the header.php and navigation.php - now as I am writing this I am realizing that the navigation.php does not get the css file imported into it, but does the validator not just read the html? so there it should pick it up and see that it gets the information?
Please let me know if I am on the right track with this, otherwise it seems that you sacrifice validation for a structured website??
Cheers Jeff PS Happy New Year:-)
EDIT CODE:
URI: http://thepalmsmarket.co.nz/index.php a
276 9 there is no attribute "id" a
276 24 there is no attribute "class" a
276 38 element "nav" undefined
I these are the last errors and they are related to this code:
index.php:
<?php include_once ("01includes/header.php"); ?>
</head><!--hmtl tag closes in the footer-->
<body class="no-js"><!--The script here is to disable the class put into the body tag if javascript is enabled.-->
<?php include_once ("01includes/navigation.php"); ?>
navigation.php:
<nav id="topNav" class="centeredmenu">
<ul>
<?php
$subject_set = mysql_query("SELECT * FROM webMenu", $dbconnect);
if (!$subject_set) {
die("Database query failed: " . mysql_error());
}
while ($subject = mysql_fetch_array($subject_set)) {
echo "<li class=\"{$subject["class"]}\">{$subject["menuItem"]}</li>"; }
?>
</ul>
The css is declared in desktop.css which is imported into header.php, but not into navigation.php as that would be a double up - hope that makes sense:-)
Good news: nothing to do with PHP. You appear to be using the nav tag, which is new in HTML5, while validating against the XHTML 1.1 Strict. If you switch to an HTML5 declaration, so that you can use nav in a nice, valid, semantic way, then you'll have to chase down a few other validation errors (mostly related to the meta tags, and then use of a deprecated border attribute further on in your code -- the validation errors should be self-explanatory). If you want to keep on with XHTML, then drop the use of nav to be valid.