Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Hi I am web designer and I would like to know how to set menu subtitle? It is easily possible with yoo themes but I need to know how it is done without using YooTheme templates. I think there is need of little modification in mod_menu but I don't know what exactly. I googled all day and can't find a solution.
There are certainly better solutions but i've done it this way:
Insert a charakter in the name of your menu-item. For example a "|".
It should look like this: Title | Subtitle. At this position you can divide the name.
Now you have to override the file default_component.php in modules/mod_menu/tmpl.
Add this lines:
$parts = explode("|", $linktype);
// the "|" is the divider
if(isset($parts[1])){
$linktype = $parts[0].'<span>'.$parts[1].'</span>';
}else{
$linktype = $parts[0];
};
after:
$class = $item->anchor_css ? 'class="'.$item->anchor_css.'" ' : '';
$title = $item->anchor_title ? 'title="'.$item->anchor_title.'" ' : '';
if ($item->menu_image) {
$item->params->get('menu_text', 1 ) ?
$linktype = '<img src="'.$item->menu_image.'" alt="'.$item->title.'" /><span class="image-title">'.$item->title.'</span> ' :
$linktype = '<img src="'.$item->menu_image.'" alt="'.$item->title.'" />';
}
else { $linktype = $item->title;
}
Now you have a span around the subtitle and it's possible to style it.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Given I'm using the following code:
$images = get_attached_media('image' ); // get attached media
foreach ($images as $image) {
$ximage = wp_get_attachment_image_src($image->ID,'medium');
echo '<img src="' .$ximage[0] . '" />';
}
How can I limit it to just show the first attached image only, rather than all of them?
If you only want to show first image from array, remove the foreach loop and do this:
$images = get_attached_media('image' );
// get first element from array
$image = reset($images );
$ximage = wp_get_attachment_image_src($image->ID,'medium');
echo '<img src="' .$ximage[0] . '" />';
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
echo <a href = 'test.php'> "CategoryID: " . $row["CategoryID"]. " - Category Name: ".$row["CategoryName"]. </a> "<br>";
This is what i have an is not working properly.
This:
echo "<a href = 'test.php'>CategoryID: {$row['CategoryID']} - Category Name: {$row['CategoryName']}</a><br />";
I am using the { and } as they allow you to include an array in a string and ignore the concatenation which I find harder to read.
I find it funny that you can loop through a MySQL array but can't echo a simple string :P
Some links (teach a man to fish...):
W3Schools
PHP documentation
Codecademy
Tutorials Point
Try this:
<?php
$link = "";
$link = sprintf("<a href = 'test.php'>CategoryID: %d - Category Name: %s </a><br />", $row['CategoryID'], $row['CategoryName']);
echo $link;
?>
Assuming that $row['CategoryID'] is an integer and $row['CategoryName'] is a string.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
my HTML code is THE CODE IS REPEATED 16 times :
<div class="headline_image">
<a ga-cat="slideshow-view" ga-action="view-1" href="mylink"><img src="http://dd4994.jpg" width="420" height="323" align="right" alt="my text "/></a>
</div>
I WANT TO GET all the imgs links and text also href what i did :
for ($x = 0; $x <= 15; $x++) {
$imglink = $html->find('div[class=headline_image] img', $x)->getAttribute('src');
$mytext = $html->find('div[class=headline_image] img', $x)->getAttribute('alt');
$postlink = $html->find('div[class=headline_image] a', $x)->getAttribute('href');
echo '<br/>';
echo $mytext;
echo '<br/>';
print_r($postlink);
echo '<br/>';
}
the code is slow any changes ?
You slow down your code by using too much anonymous objects. It means you don't put the result of the function into a variable, rather just use it "on the go". This needs to run your function again and again slowing down your project.
Because you can use the function find to return an array, I advice you to do so before the for loop.
$imgarray = $html->find('div[class=headline_image] img', $x);
This way you run $html->find exactly once, and not sixteen times. In the for loop you can use it as an array and work with the results: $imgarray[$x]. You make the same for $anchorarray and your code will speed up, you'll see.
Alternative solution is using PHP DOM $childNodes on the container in which this 16 item can be found (or the body element). This will return the sixteen div elements in which you can navigate by calling $firstChild for the <a> element and $firstChild again for the <img> element. Probably this is more secure in case you want to make changes to the website (like adding more content to the end etc.)
Hey Daniel i changed the code to :
$imgarray = $html->find('div[class=headline_image] img');
$linkarray = $html->find('div[class=headline_image] a');
for ($x = 0; $x <= 15; $x++) {
echo $imgarray[$x]->getAttribute('src');
echo '<br/>';
echo $imgarray[$x]->getAttribute('alt');
echo '<br/>';
echo $linkarray[$x]->getAttribute('href');
echo '<br/>';
}
In general the proper way to iterate looks like this:
foreach($html->find('div') as $div){
echo $div;
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to make variables of these red block parts
(screenshot).
PHP code:
echo do_shortcode('[product_category category="others" per_page="12" columns="4"]');
You can directly insert variable values in a "" delimited string in PHP.
$cat = "some_category";
$per = 20; // some number
$col = 10; // some number
echo do_shortcode("[product_category category=\"$cat\" per_page=\"$per\" columns=\"$col\"]");
If you still want to use a '' delimited string, you need to append values together.
echo do_shortcode('[product_category category="' . $cat . '" per_page="' . $per . '" columns="' . $col . '"]');
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
My Joomla and virtuemart have a product price salesPrice that is shown by this:
echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices);
Now I need to convert salesPrice to $customprice so I can calculate it in code like this:
<?php
$customprice = ('salesPrice');
$cijenaraw = str_replace(' Kn','',$customprice);
$cijenaraw2 = str_replace('.','',$customprice);
$cijenaraw3 = str_replace(',','.',$cijenaraw2);
$dicscijena = ($cijenaraw3 / 100) * 92;
$novacijena = round($dicscijena, 2);
echo '<p style="margin-top:10px;color: #FF7800;"><strong>*Cijena: '. number_format($custompricefinal, 2, ',', '.') .' HRK</strong></p>';
endif;
?>
The problem is that $customprice = ('salesPrice'); can't give you any value.
If you are using the script in the product details page you have to add:
$customprice = $this->product->prices['salesPrice'];
If it is in the category browse page:
$customprice = $product->prices['salesPrice'];
Now $customprice would have the sales price that you could make calculations.