I searched in API without success.
There is an incomplete description of the keys of $htmlOption.
I am particularly interested in some public methods like "fileField($model, $attribute, $htmlOptions=array ())" and others of class CActiveForm.
In general, the $htmlOptions array is described by the HTML element being generated. The array is literally the "attributes" of the HTML element. The keys are the attributes names. So if you are generating an image with CHtml::Image then "src" is a valid $htmlOption key. If you generating a CHtml::Link, then "href" is a valid $htmlOption key.
If you look in the documentation, the description for $htmlOptions parameter of the CHtml::link() element is:
additional HTML attributes. Besides normal HTML attributes, a few special attributes are also recognized (see clientChange and tag for more details.)
I usually use the $htmlOptions array to add classes, IDs or styles to an HTML element, like so:
<?php echo CHtml::link("Click Me","http://stackoverflow.com",array("id"=>"myId","class"=>"class1 class2","style"=>"color: #f00;")); ?>
This would render the following code:
Click Me
There are a couple of extra "special" AJAX options that Yii allows in the $htmlOptions array for some elements (link, button, and a few others). They let you create AJAX links, add JS confirm popups, etc. These options are described here:
http://www.yiiframework.com/doc/api/CHtml#clientChange-detail
For the fileField element, you can look up the relevant attributes here which will be allowed in the $htmlOptions array.
Related
I have an extension that dynamically creates content for some pages.
E.g. I have creates headlines with the <html> <h1>, <h2> and <h3>.
I want my mediawiki to react to the headline tags to create a directory dynamically.
I already tried using == in the specific tags in my extension, but mediawiki simply creates the string which will be displayed.
How can I achieve my goal?
Thanks in advance.
Are you hooking to ParserFirstCallInit?
You may need to parse the wikitext that you're returning, before returning it. Use something like $out = $parser->recursiveTagParse( "== Wikitext here ==" );
Alternatively, if you just want to return raw HTML, you can return an array of the form [ 0 => $outputHtml, 'isHTML' => true ].
I'm not sure what you mean by "create a directory dynamically" but if you're just trying to create HTML in a wikipage then the above should work.
I'm using dynatree and generating my dynatree out of json.
Is it possible that I've an extra attribute (data_key) in my fields so I can work with the dynatree with my PHP as well? I want a hover effect on the icons from the dynatree, the pop-up that is coming up, needs to have some data of the "hovered" node.
Somebody an answer?
Custom properties that you add to the JSON child array will be copied to node.data.
So if you pass [{"title": "node 1", "myAttr": "foo"}, ...] you can accesss it like node.data.myAttr.
Using PHP, I need to read in a csv file of id's...
0123,0456,0789
... then load a SVG XML graphics file and change the color attribute of those specific id's.
Each polygon in the SVG file has records like below. I need to change the fill: values in every matching record from #d0d0d0 to #FF0000. Outer loop will be the ids of course, inner will be each record of the SVG file.
style="font-size:12px;fill:#d0d0d0;fill-rule:nonzero;stroke:#000000;stroke-opacity:1;stroke-width:0.1;stroke-miterlimit:4;stroke-dasharray:none;stroke-linecap:butt;marker-start:none;stroke-linejoin:bevel"
d="M 131.85275,310.64335 L 131.85275,311.08435"
id="0123"
For my hobbyist level of programming skill, a general PHP structure of the loops needed plus tips how to access specific attributes of style would be very helpful!
Thanks!
Brian
The DOMDocument object has getelementbyid, getAttribute and setAttribute, which should let you change the xml.
This example looks similar to what you're wanting, once you get the styles you can explode with ';' to get the array of styles, then join with the new styles.
I'd recommend a different approach: Use CSS for changing the color. No looping over SVG elements required there. To be able to do this, you should clean up the SVG file a little, which also will make it more compact.
As I understand it, all your to-be-colored elements have the same style attribute with content
font-size:12px;fill:#d0d0d0;fill-rule:nonzero;stroke:#000000;stroke-opacity:1;stroke-width:0.1;stroke-miterlimit:4;stroke-dasharray:none;stroke-linecap:butt;marker-start:none;stroke-linejoin:bevel
Delete those attributes, replace them with a sensible class attribute. Let's say those paths are countries on a map, then lets give them an attribute class="country". Then style all of those using one CSS rule, like:
.country {
fill: #d0d0d0;
fill-rule:nonzero;
stroke:#000000;
stroke-opacity:1;
stroke-width:0.1;
stroke-miterlimit:4;
stroke-dasharray:none;
stroke-linecap:butt;
marker-start:none;
stroke-linejoin:bevel;
}
I left away the font-size property as this is irrelevant for a <path> element. (Probably you can simplify this further because a lot of properties repeat the default values, and unless you change those properties in a parent element of your paths, fill-rule, stroke-opacity, stroke-miterlimit, stroke-dasharray, stroke-linecap and marker-start are redundant, but don't hurt anyone.)
There is one more problem: If the IDs in your file look indeed like 0123, 0456 or 0789, those are invalid because they need to follow the rules for XML names, which must not start with a number. You should expect problems when trying to style those elements using their IDs or when trying to use getElementById() on them. So, you might want to change them to something like id0123, id0456 and id0789
Now, you can dynamically add some CSS from your CSV data.
0123,0456,0789
would become
#id0123,#id0456,#id0789 {fill:#FF0000}
and you're done. The CSS can be added to a <style> element of your SVG file, or you create a separate CSS file and reference this from the SVG. This way, you don't have to do any changes to the SVG when dynamically changing the colors. If you use the SVG data inline in HTML, you can also add this to a <style> element in your HTML page or a CSS file that's referenced by the HTML.
Updating from Cake 1.2 to 1.3 and I have an image nested in a link element, both generated by the HTML helper. The nested image's markup is however escaped from < to > ect. I know the HTML helper now escapes stuff by default, but I can't get it to change this behavior.
This is the code generating an example image link:
$html->link($html->image('icons/small/navigation-back.gif', array('alt'=>"Move Left", 'border'=>"0"))
,'#',array('id'=>'options_left'), array('escape'=>false))
I added the array('escape'=>false) bit from the official Cake documentation (part of the $options array), but I still get escaped image tags. Is the order set wrong or did more change than I'm aware of? The original code is straight from cake 1.2.
the third parameter is the options array:
$html->link($html->image('icons/small/navigation-back.gif', array('alt'=>"Move Left", 'border'=>"0"))
,'#',array('id'=>'options_left', 'escape'=>false))
I am attempting to display HTML information in an attribute of a XML document. For example, I somehow want to accomplish the following:
Attributes:
id = "id"
HTML_Elements = {
link
}
(<something id='id' HTML_Elements='code'></something>)
I am wondering if there is some way to accomplish displaying the code directly inside of the attribute without having to link to it on another page.
Thanks for any help!
XML attributes may not contain HTML.
See Chapter 3.3.3 Attribute Value Normalization in the XML 1.0 Specs