I'm going mad. I get the value (it's the address of an home) from a Wordpress custom field (input type) with this code:
<?php $dudi=get_post_meta($post->ID, 'addr', true); ?>
It's good! Now I have to "pass" this variable $dudi to a jQuery function (it's gMap, for display Google maps):
$(function() {
$("#map").gMap({ markers: [
{ address: '<?php echo $dudi; ?>',
html: "blah blah<br>blah blah" }
],
zoom: 10 });
});
and now with the tag <div id="map"></div> gMap should display the map with the marker on the specified address (value in the variable $dudi) but doesn't work!
Notice that if I manually write the address (in place of <?php echo $dudi; ?>) it works on Chrome with bugs (strange effects when click the marker and move the map) and don't works on IE and Firefox
Don't know... I've tried in any way but nothing to do... and I need this for tomorrow! :(
Hope in you guys!!
UPDATE:
Oh my God! I'm going for steps because it's not clear if the issue is caused by the passing of the variable or by a html/css conflict. So for the moment I have manually written the address in the jQuery function bypassing the variable.
Well, after many headaches I've found that the map goes in conflict with the css:
max-width: 100%;
Infact, when I comment that line the map shows correctly.
NOW, I restored the variable and now the map doesn't work on any browser (aka gray backgroud) BUT it shows correctly the zoom fader and in the browser console I have two errors TypeError: a is null in the file main.js. Unfortunately I don't know this file and I'm not able to fix some codes.
Hope you guys... again!
if needed...
1st error
H(ff,hb);var Kh=256/360,Lh=256/(2*Math.PI);ff.prototype.fromLatLngToPixel=function(a,b){var c=128+a.lng()*Kh,d=Db(Math.sin(Xb(a.lat())),-0.9999,0.9999),d=128+0.5*Math.log((1+d)/(1-d))*-Lh,f=1<<b;return new r(u(c*f),u(d*f))};
2nd error
Oh(Sj,"arrow",1);function qi(a,b,c){!a.lat&&!a.lon&&(a=new P(a.y,a.x));this.Aa=a;this.Nu=i;this.na=0;this.N=this.mb=!1;this.Oo=[];this.V=[];this.Ra=Mj;this.Mg=this.cl=i;this.Ub=!0;this.Dg=this.rf=!1;this.g=i;if(b instanceof Qj||b==i||c!=i)this.Ra=b||Mj,this.Ub=!c,this.ha={icon:this.Ra,clickable:this.Ub};else{b=this.ha=b||{};this.Ra=b.icon||Mj;this.mv&&this.mv(b);if(b.clickable!=i)this.Ub=b.clickable;if(b.isPng)this.rf=!0}b&&Ob(this,b,"id,icon_id,name,description,snippet,nodeData".split(","));this.Zu=Tj;if(b&&b.getDomId)this.Zu=
"Chrome shows the map with the marker OK!!! While Firefox and IE don't
show nothing (gray background, etc)"
If Ennui's solution works fine at Chrome, then check the other browsers consoles - they should output some kind of errors. That's what usually happens when GoogleMaps show 'gray background' instead of a map.
A quick and dirty solution would be to echo the $dudi variable somewhere on the page in a hidden div. For example:
<p style="display:none" id="dudi">
<?php echo get_post_meta($post->ID, 'addr', true); ?>
</p>
Then in your jQuery:
var dudi = $('p#dudi').text();
Didn't have time to test this but I think it should work for your purposes.
try to find css stype for img tag
max-width: none;
and replace it to:
max-width: none;
Related
I have a social netowork coded in PHP and css. Ive realized that it looks so much nicer and cleaner when its zoomed out at 90% instead of 100%. Is there a piece of code I can implement into the php or css to make the webpage automatically zoom out when its visited? This is mainly only for the login page.
if you want to take a look at the site, heres the URL: social.flamboyantent.co.uk
Thank you in advance.
If I understood you right.
This should work:
<script type="text/javascript">
function zoom() {
document.body.style.zoom = "90%"
}
</script>
<body onload="zoom()">
To add zoom in Firefox read this object.Style.Zoom property not working in Firefox
Last answer will work for major browsers.
<script type="text/javascript">
function zoom() {
document.body.style.zoom = "90%"
}
This is the compatibility chart.
But as stated in THIS QUESTION
You could use the "proprietary" -moz-transform property in Firefox 3.5+.
So you could use:
div.zoomed {
zoom: 3;
-moz-transform: scale(3);
-moz-transform-origin: 0 0;
}
And there´s also a BUGZILLA ticket.
Bugzilla
I have a small problem with my PHP code and It would be very nice if someone could help me. I want to display an image when hovering over a link. This is the link with the PHP code that I have now:
<?php if ( has_post_thumbnail() ) {the_post_thumbnail();} else if ( has_post_video() ) {the_post_video_image();}?>
This code shows a image, but I want to execute this code when hovering over the link with the image:
<?php echo print_image_function(); ?>
The code also shows a image that belongs to a category. I don't want the initial image to disappear I simply want to show the second image on top off the first image when hovering over the first image.
I don't know if it is helpful but I use Wordpress and I am not a PHP expert. I even don't know if this is going to work. Thats why I am asking if somebody can help me with this.
Thanks in advance
THANKS EVERYONE
I want to thank everybody that took the time to read my post and helped me by giving their solution.
I didnt exspect so many answers in such a fast time. After spending a few hours trying it to get it to work with PHP, CSS and Javacript, I stumbled upon the following question on this website: Solution
It was exactly where I was looking for and with a few modifications to fit my needs, I got it to work. Sometimes things can be so easy while you are looking for the hard way. So for everyone that has the same problem: You can use one of the solutions that where given by the awesome people here or take a look at the link above.
Thanks again! :)
You can do this with CSS (if you so please and this fits with your overall architecture) - here is an example using the :hover condition and :after pseudo element.
html
<img src="http://www.gravatar.com/avatar/e5b801f3e9b405c4feb5a4461aff73c2?s=32&d=identicon&r=PG" />
css
.foo {
position: relative;
}
.foo:hover:after {
content: ' ';
background-image: url(http://www.gravatar.com/avatar/ca536e1d909e8d58cba0fdb55be0c6c5?s=32&d=identicon&r=PG);
position: absolute;
top: 10px;
left: 10px;
height: 32px;
width: 32px;
}
http://jsfiddle.net/rlemon/3kWhf/ demo here
Edit:
Always when using new or experimental CSS features reference a compatibility chart http://caniuse.com/ to ensure you are still in your supported browsers. For example, :after is only supported starting IE8.
You cannot randomly execute server side code on the client side.
Try using javascript AJAX requests instead.
PHP is a server-side language; you can't get PHP to execute after the page has loaded (because PHP completely finishes parsing before the page loads). If you want hover events, you need JS.
Firstly you don't need the elseif statement. An else will serve the same purpose, unless you intend to have blank tags where neither a thumbnail or a video image are present.
<a href="<?php the_permalink(); ?>">
<?php
if ( has_post_thumbnail() )
{
the_post_thumbnail();
}
else
{
the_post_video_image();
}
?>
</a>
You can't explicitly use PHP for client side functionality. You will need to use javascript or jquery to supply the on hover capability.
Jquery example:
$(function() {
$('a').hover(function() {
// Code to execute whenever the <a> is hovered over
// Example: Whenever THIS <a> tag is hovered over, display
// the hidden image that has a class of .rollover
$(this + ' .rollover').fadeIn(300);
}, function() {
// Execute this code when the mouse exits the hover area
// Example (inline with above example)
$(this + ' .rollover').fadeOut(300);
});
});
To have an image placed on top of another image you would need to make sure your CSS uses absolute positioning for the images with the image that is to overlay the other on hover is given a z-index value higher than the image to sit underneath it.
Hope this helps.
You'll need some JavaScript and/or CSS to make this work, since PHP is on the server side, not in the client browser.
I am building a website that displays recipes. Each recipe appears as part of a blog entry, and will have a link at the bottom to Print this recipe.
What I want to happen is a click on the link opens a new window and fills it with a print-friendly-styled version of the recipe, which is already inside its own <div class="recipe">.
Can I do this with JS/jQuery alone, or do I need to process from the server side? Any ideas how to do this?
EDIT: What would be ideal would be to generate a PDF on the fly, but in lieu of that I'd like a new window, containing only the recipe, for the visitor to print out or save, as they see fit. Print-styles are nice, but most people don't know they exist and can't be bothered to check and see by printing out a page that doesn't look print ready.
There is no need to load a different stylesheet and the only javascript you will need is for triggering the printing dialog.
With CSS alone you can add rules that are only used when printing, you can either use media queries
<style type="text/css">
#media print{
//css printing rules
}
</style>
or use the link tag:
<link rel="stylesheet" media="print" href="styles.css" type="text/css" />
UPDATE: If you want to update the stylesheet on the fly without openning a new window i suggest you check out this Nettuts article or a simpler solution:
$("#css-switch").click(function() {
$("link[rel=stylesheet]").attr({href : "red.css"});
});
You can do this simply with CSS alone if you have it load the exact same page but with a different stylesheet.
Yes, you can(Hello Mr. Obama).
Most browsers allow you to pass in a data: format string, like
window.open('data:text/html;charset=utf-8,text%20to%20show');
which would open a new window / tab (that is browser config dependend) with the Content "text to show". You can pass in HTML code in the same manner, probably escaped.
var print = $('<div>', {
id: 'foobar',
html: 'Hello world',
css: {
backgroundColor: '#ff0000',
color: '#ffffff',
width: '200px',
height: '200px'
}
}),
opener = $('<div>').append(print);
window.open('data:text/html;charset=utf-8,' + opener.html());
Demo: http://www.jsfiddle.net/4yUqL/73/
You'll probably need to do a request to the server on the print page and fill in the form fields with the data.
If i was you, i'd go for the pdf creating solution. It is fairly simple to create pdf's on the fly in php, and it will almost certainly give a better user experience to your main audience.
If you want to skip that excersise, i'd do it the following way:
1: fetch the data you need as JSON on the original non-printerfriendly page, and use clientside templating to build the ui. Store the JSON for use on the printerfriendly page
2: when you open the new window, use the exact same method, but use another template optimized for printing.
Is it possible to run the Cufon text replacement script in PHP (or before its sent to the browser)? The reason I ask is that there is a bit of an issue with the displayed HTML being its normal browser rendered text before Cufon is able to draw its magic over it. The user sees a flash of unrendered text (FOUT) before it is replaced with Cufon's awesomeness. I've noticed that the rendered HTML has some tags generated in place of the HTML (canvas and Cufon tags) text and I thought, what if this could be done in PHP and then sent to the browser so that the browser actually receives the drawn text from the start?. Would this mean porting over the code that draws the text to PHP? This came as a stroke of genius or more likely stupidity last night and was wondering if anyone had some thoughts on the matter. Thanks for reading.
Cufon.replace('div#nav-menu a h5',{
fontFamily:'United Stencil',
hover: true,
hoverables : {h5 : true}
});
Cufon.replace('.stencil',{fontFamily:'United Stencil'})
Cufon.replace('.heavy',{
fontFamily : 'United Heavy',
hover : true,
hoverables : {
h1:true,
h2:true,
h3:true
}
});
Here is the Cufoned HTML:
<a class=" heavy" href="/mp_svn/node/5">
<cufon class="cufon cufon-canvas" alt="Products" style="width: 65px; height: 16px;">
<canvas width="77" height="17" style="width: 77px; height: 17px; top: -2px; left: -2px;"></canvas>
<cufontext>Products</cufontext>
</cufon>
I would like to send the above HTML to the browser from the beginning, pre-Cufon it is something like:
Products
Cufon has a callback function that runs after all text has been replaced: http://groups.google.com/group/cufon/browse_thread/thread/20a8d2edd45f1aa5/1a498d21856405cd
You could either
Initially hide the content with CSS, then show it with javascript in the callback, and be absolutely sure you will have no FOUT--but your page will be totally inaccessible for users without JS
Or, hide the content with JS when the DOM is ready, and then show it again after the text replacement has occurred. Using jQuery,
$(document).ready(function(){
$('#content').css('visibility', 'hidden');
Cufon.CSS.ready(function() {
$('#content').css('visibility, 'visible');
});
});
This should work fine for Firefox/webkit, but there will still be a FOUC in IE before the JS takes effect. You could also use $('#content').fadeTo(0, 0); if you want to be able to fade in the content once it's been replaced by Cufon.
EDIT
I have figured out a superior way. You go with the #1 approach, hiding content with CSS, but then you throw in a <noscript> area with a style declaration that resets visibility:visible
That way there will be absolutely no FOUC, and if JS is enabled, they won't have a problem either.
You could use Cufon's built in function
Cufon.now();
So there's no flash when replacing the text.
Great idea, and it's something people have been doing for a while. Here's an early one from 2004: http://www.alistapart.com/articles/dynatext/
And a few newer ones
http://artypapers.com/csshelppile/pcdtr/
http://www.joaomak.net/util/dtr/
I set my visibility to false in css, call the replace function on Cufon and use the onAfterReplace callback to set the element to visible.
$(document).ready(function(){
Cufon.replace('h1', { fontFamily: 'alwyn-thin',
onAfterReplace:function(el,options){
$(el).css('visibility', 'visible');
}});
I just asked a question here, about why an iframe_resize function wasn't working.
After troubleshooting, I found out that the problem is not the function, so I am posting a new question.
I have an index.html with this resize function:
function resize_iframe(new_height){
document.getElementById('iframe001').style.height=parseInt(new_height) + 20 + 'px';
}
Then I have a form in index.html with target set to an iframe, and action set to query.php:
<form action='query.php' target='iframe001'>
The in my query.php:
//ALOT OF PHP HERE
<body onload="parent.resize_iframe(document.body.scrollHeight)">
<?php echo $results_table; ?>
</body>
The problem is, in Chrome and Safari, the scrollHeight isn't changed at all.
In all other browsers, scrollHeight changes and the function works.
However, in Chrome/Safari, when clicking on a link anywhere on the page, and then clicking on the browser back button to return to the search results (iframe content), THEN the iframe is resized properly even in Chrome/Safari... ?
This is very strange behaviour for me.
Can somebody explain this?
Thanks
PS: I think this person has the same problem: iframe resizing with scrollheight in chrome/safari
Did you try offsetHeight property?
It seems there is a bug in general with webkit browsers. https://bugs.chromium.org/p/chromium/issues/detail?id=34224&can=2&start=0&num=100&q=&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified&groupby=&sort=
WORKAROUND(!): I had margin applied to a wrapping element like this inside the iframe:
<div class="wrapper" style="margin-top: 30px"><!-- ... content --></div>
changed it to be instead:
<div class="wrapper" style="padding-top: 30px"><!-- ... content --></div>
then scrollHeight is correct :)