I have a linked image that I need to specify height and width html attributes for that is generated by php string. I've looked into using getimagesize but its not looking like what I need. I am currently using social engine.
This is the string I have that calls the image link.
<?php echo $this->htmlLink($item->getHref(), $this->itemPhoto($item, 'null'), array('class' => '')) ?>
which outputs html somthing like <img src="#" class="null"/>
I need to modify the php to create an image that is specified to be 110px x 110px
ie <img src="#" class="null" width="110" height="110"/>
Can anyone give me an example of how I could write my string?
You have to use this:
<?php echo $this->htmlLink(
$item->getHref(),
$this->itemPhoto(
$item,
'null',
null,
array('width' => '110px', 'height' => '110px')),
array('class' => '')
) ?>
That is, add a fourth parameter array to itemPhoto function.
Socialengine is an extension of Zend framework. You should try to check out the definition of itemPhoto, htmlLink etc. functions in order to customize them. For example itemPhoto can be found here- \application\modules\Core\View\Helper\ItemPhoto.php
The last parameter is used for that, isn't that?
$this->htmlLink(
$item->getHref(),
$this->itemPhoto($item, '', '', array('width' => 110, 'height' => 110)),
array('class' => '')
);
Method1:
Just add style for null class
<?php echo $this->htmlLink($item->getHref(), $this->itemPhoto($item, 'null'), array('class' => '')) ?>
as:
.null {
height: 110px;
width: 110px;
}
Method2:
Or you can pass a inline style attribute as:
<?php echo $this->htmlLink($item->getHref(), $this->itemPhoto($item, 'null'), array('class' => '', 'style' => 'height: 110px; width: 110px')) ?>
I cant see whats behind the function htmlLink() but I guess due to the name of those elements you pass you could just write.
echo '<img src="'.$this->itemPhoto($item, 'null').'" class="null" width="110" height="110"/>';
but ether post that function or just try and error!
Related
I want to add style ' float:right ' for this text. I tried some way,but not works. How should i add inline css for this.
public function title()
{
return $this->t('You have {amount} of credit',
array('{amount}' => m('payment')->format(wm()->get('payment.helper')->credit())),
array('style'=>'float:right'));
}
Can you give me a hint, please?
Yii translation function looks like this: Yii::t('category', 'message', \['params' => 'value'\]). So you need style to be in your message to translate it.
Yii::t(
'admin',
'You have <span style="{style}">{amount}</span>',
[
'{style}' => 'color: red;',
'{amount}' => 'Test',
]
);
-> <span style="color: red;">Test</span>
Agree with #Justinas, (Great thanks for your example, it really works) but there one tiny mistake in your code:
'{style}' => 'color: red;' // in this case style would not be applicable to a span
has to be so:
'style' => 'color: red;'
Tested on my case, works for sure.
I am looking for a way to modify the default Views feed icon from an image to a text value. I have found several cases where people change the default image to a new image, but I prefer working with fonts as they look more crisp regardless of resolution or device.
The idea is to replace the image with a FontAwesome icon (fa-rss-square, ). I have had succes with changing the default text in the search-block, ie.:
function theme_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'search_block_form') {
$form['actions']['submit']['#value'] = decode_entities('');
}
}
I am a newbie when it comes to php, so my attempts of modifying the hook explained in the Drupal-API has not worked (thus far):
function theme_feed_icon($variables) {
$text = t('Subscribe to !feed-title', array('!feed-title' => $variables['title']));
if ($image = theme('image', array('path' => 'misc/feed.png', 'width' => 16, 'height' => 16, 'alt' => $text))) {
return l($image, $variables['url'], array('html' => TRUE, 'attributes' => array('class' => array('feed-icon'), 'title' => $text)));
}
}
The current output looks like this:
<div class="feed-icon">
<img typeof="foaf:Image" src="mywebsite/misc/feed.png" width="16" height="16" alt="Subscribe to news from my website">
</div>
I'd like to keep the div and its class, but only have the font/text link inside, preferably without the same class. I'd appreciate any clever advice :-)
you could avoid printing the feed icon from php and just enter the html code either in the footer or the header of the view from the UI
or
you could hide the image via CSS, and use
.feed-icon:before {
font-family: FontAwesome;
content: "\f143";
}
This is the original php code:
function lovethemes_pricing_shortcode($atts)
{extract(shortcode_atts(array(
"heading" => '',
"price" => '',
"link" => '',
"name" => '',
), $atts ) );
return '<div class="pricing animated bounceIn">
<section class="head">'.heading.'
<section class="content">
<ul><li class="price">'.$price.'</li>
<li>'.$name.'</li>
</ul></section> </div>';}
add_shortcode('pricing', 'lovethemes_pricing_shortcode');
This is what is written on my page in the backend:
[pricing heading="7 februari 2015"
price="Strak bekleden van een taart"
link="/agenda/workshops/strak-bekleden-van-een-fondant-taart"
name="Info"]
Resulting in this:
http://www.alexandra-van-zandbergen.be/wp-content/uploads/2015/08/Schermafbeelding-2015-08-08-om-13.23.38.png
And what I would like to have is this:
http://www.alexandra-van-zandbergen.be/wp-content/uploads/2015/08/Schermafbeelding-2015-08-08-om-13.22.47.png
I can read and write html and css but no php... Can anyone help me with this please? I've tried to add several codes and nothing is working.
I have to be able to change the image in the backend, I would like to be able to just choose an image from the Wordpress image gallery.
Thanks in advance!
Alexandra
I'm not very familiar with it either, and would need to try it to see if it works, so pls don't shoot me if it does not. However, this function makes use of the shortcode API.
The code tells to create a [pricing] shortcode, currently with 4 attributes. So, if all the rest works, then you most likely can simply add another one.
What I do not understand - and I'm not taking the time to look it up - is why all variables in your code start with $, but not the heading. I'll ignore that since it doesn't seem to be the problem.
Note:
It's best to add:
the image size to the HTML for performance. I'm assuming that you'll
use images of the same size. If you would want to set the image
size, you can create attributes for it too.
an alt text for SEO. Below I use the price attribute.
While I'm at it I would suggest to add a link to the image and title too. People sometimes click on it instead of on the info button. This would make it more user friendly.
So, it then would look like this:
function lovethemes_pricing_shortcode($atts) {
extract(shortcode_atts(array(
"heading" => '',
"price" => '',
"link" => '',
"name" => '',
"img" => '',
), $atts ) );
return '<div class="pricing animated bounceIn">
<section class="head">'.heading.'
<section class="content">
<ul><li class="price">'.$price.'</li>
<li><img src="'.$img.'" alt="'.$price.'" width="247" height="186" /></li>
<li>'.$name.'</li>
</ul></section></div>';
}
add_shortcode('pricing', 'lovethemes_pricing_shortcode');
and your shortcode would be:
[pricing heading="7 februari 2015"
price="Strak bekleden van een taart"
link="/agenda/workshops/strak-bekleden-van-een-fondant-taart"
img="/your/image/url.jpg"
name="Info"]
To make it a little more user friendly, you could also rename the attributes to something that corresponds to the content, f.ex. heading > date
I hope this helps!
l(t('Edit'), 'node/' . $node->nid . '/webform/components/' . $cid, array('query' => drupal_get_destination())),
I'd like to be able to replace the word "Edit" with an image instead, however when I put an image src in there it shows up as text. Is there a different function I should be using?
I'm using Drupal as my framework.
Thanks ffrom a noob.
Best way to do this is to combine l() and theme_image():
print l(theme_image(array('path' => 'edit_button.png', 'attributes' => array('title' => t('Edit')))), 'node/' . $node->nid . '/webform/components/' . $cid, array('query' => drupal_get_destination(), 'html' => TRUE));
You should also use drupal_get_path() to prefix the path of your image.
This way you will fully apply to the Drupal Coding standards, and make your life easier.
That button should have its own class, for example, action_button or an id such as edit_button. Now use CSS to hide the text and use a background image in its place as shown below:
.action_button, #edit_button {
/* Hide Text */
text-indent: -9999px;
display: block;
background: url('edit_button.png') no-repeat;
/* Set width and height equal to the size of your image */
width: 20px;
height: 20px;
}
EDIT 1:
Change your code with below and use above CSS:
l(t('Edit'), 'node/'.$node->nid.'/webform/components/'.$cid, array('attributes' => array('id' => array('edit_button')), 'query' => drupal_get_destination()));
EDIT 2 [FINAL]:
Passing html as TRUE to array parameter of l() method can make us able to use first parameter as img tag instead of just text for display as link:
l('<img src="edit_button.png" alt="Edit" />', 'node/'.$node->nid.'/webform/components/'.$cid, array('query' => drupal_get_destination(), 'html' => 'TRUE'));
This is the best way I implemented:
list($nodeImage) = field_get_items('node', $node, 'uc_product_image');
$style_array = array('path' => $nodeImage['uri'], 'style_name' => 'MY_IMAGE_STYLE');
$render_node_image = theme('image_style', $style_array);
$render_node_image_WITH_LINK = l($render_node_image, 'node/' . $node->nid, array('html' => TRUE));
print $render_node_image_WITH_LINK
I am trying to get CKEditor to use an unique ID that I can use some jQuery to grab the value within a ajax request.
Can anyone suggest how I can set the ID for the editor?
Below is the code
http://pastebin.com/eTP7xnKr
Try something like this, you can also set many other attributes:
$CKEditor->textareaAttributes = array("id" => $fieldname, "cols" => 40, "rows" => 4, 'style' => "width: {$width}; height: {$height}; position: relative; overflow: auto;");
Have a look in ckeditor.php it will tell you how.
Sorry, I don't have a clever answer...