Forum Replies Created
- AuthorPosts
-
abctest483Membera) you can put other items inside an a tag, it will work but it’s unsemantic.
b)
- put your iframe in a hidden div (or ajax it in on click)
- the do $(‘.menuitem’).click(hiddendiv.fancyb…().show())
Personally i would always avoid using onclick=”” it’s much easier to maintain your code in an external js file
abctest483MemberYou can also use Google PDF viewer for this purpose. As far as I know it’s not an official Google feature (am I wrong on this?), but it works for me very nicely and smoothly. You need to upload your PDF somewhere before and just use its URL:
<iframe src="https://docs.google.com/gview?url=http://example.com/mypdf.pdf&embedded=true" style="width:718px; height:700px;" frameborder="0"></iframe>What is important is that it doesn’t need a Flash player, it uses JavaScript.
abctest483MemberNote: This answer is really old and things may have changed in WordPress land since.
I am guessing that you need to detect the WordPress root from your plugin or theme.
I use the following code in FireStats to detect the root WordPress directory where FireStats is installed a a WordPress plugin.function fs_get_wp_config_path() { $base = dirname(__FILE__); $path = false; if (@file_exists(dirname(dirname($base))."/wp-config.php")) { $path = dirname(dirname($base))."/wp-config.php"; } else if (@file_exists(dirname(dirname(dirname($base)))."/wp-config.php")) { $path = dirname(dirname(dirname($base)))."/wp-config.php"; } else $path = false; if ($path != false) { $path = str_replace("\\", "/", $path); } return $path; }
abctest483MemberLooking at the bottom of your wp-config.php file in the WordPress root directory will let you find something like this:
if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/');For an example file have a look here:
http://core.trac.wordpress.org/browser/trunk/wp-config-sample.phpYou can make use of this constant called ABSPATH in other places of your WordPress scripts and in most cases it should point to your WordPress root directory.
abctest483MemberUse a helper function like this:
function makeDir($path) { $ret = mkdir($path); // use @mkdir if you want to suppress warnings/errors return $ret === true || is_dir($path); }It will return
trueif the directory was successfully created or already exists, andfalseif the directory couldn’t be created.A better alternative is this (shouldn’t give any warnings):
function makeDir($path) { return is_dir($path) || mkdir($path); }
abctest483MemberTry this, using mkdir:
if (!file_exists('path/to/directory')) { mkdir('path/to/directory', 0777, true); }Note that
0777is already the default mode for directories and may still be modified by the current umask.
abctest483MemberHave a look for this code- To embed the PDF in HTML
<!-- Embed PDF File --> <object src="YourFile.pdf" type="application/pdf" title="SamplePdf" width="500" height="720"> <a href="YourFile.pdf">shree</a> </object>
abctest483MemberI use Url.Content and never have a problem.
<script src="<%= Url.Content ("~/Scripts/jquery-1.4.1.min.js") %>" type="text/javascript"></script>
abctest483MemberAre you using any other JavaScript libraries? If so, you will probably need to use jQuery in compatibility mode:
abctest483MemberIf you haven’t seen it yet, Magento and Rackspace teamed up to create a white paper on performance tuning Magento. It’s excellent.
https://support.rackspace.com/whitepapers/building-secure-scalable-and-highly-available-magento-stores-powered-by-rackspace-solutions/— edit —
Another great resource, newly available (Oct 2011) is:
http://www.sessiondigital.com/assets/Uploads/Mag-Perf-WP-final.pdf(Thanks due to Alan Storm on this one.)
December 8, 2009 at 10:15 am in reply to: How can I change an element's class with JavaScript? #9700
abctest483MemberThe line
document.getElementById("MyElement").className = document.getElementById("MyElement").className.replace(/\bMyClass\b/','')should be:
document.getElementById("MyElement").className = document.getElementById("MyElement").className.replace('/\bMyClass\b/','');
abctest483MemberFurther to Alan Storm’s recommendations on caching, there’s two things I’d specifically recommend you look into related to caching:
– Make sure caching is in memcached, rather than on disk.
I look after a couple of magento installs, and once you get any sort of load on the system, memcached starts to perform much faster. And its dead easy to change it over (relative to doing other magento stuff at least!)
Good starting point is here: http://www.magentocommerce.com/boards/viewthread/12998/P30/ – but if you’ve not used memcached at all before, its worth looking at some general info about it as well.
– Enable template/view caching.
This is a good article: http://inchoo.net/ecommerce/magento/magento-block-caching/
There are good ones on the magento site too (google magento block caching), but its down at the moment.
To add my two cents to the block caching, I’d advise you create your own blocks in /app/code/local, extending the core ones and defining the cache parameters, name them xxx_Cache and then update your layout to use these blocks instead of the core ones. This way, you avoid losing your changes or breaking the system when you upgrade magento.
abctest483MemberI’ve only been tangentially involved in optimizing Magento for performance, but here’s a few reasons why the system is so slow
-
Parts of Magento use an EAV database system implemented on top of MySQL. This means querying for a single “thing” often means querying multiple rows
-
There’s a lot of things behind the scenes (application configuration, system config, layout config, etc.) that involve building up giant XML trees in memory and then “querying” those same trees for information. This takes both memory (storing the trees) and CPU (parsing the trees). Some of these (especially the layout tree) are huge. Also, unless caching is on, these tree are built up from files on disk and on each request.
-
Magento uses its configuration system to allow you to override classes. This is a powerful feature, but it means anytime a model, helper, or controller is instantiated, extra PHP instructions need to run to determine if an original class file or an override class files is needed. This adds up.
-
Besides the layout system, Magento’s template system involves a lot of recursive rendering. This adds up.
In general, the Magento Engineers were tasked, first and foremost, with building the most flexible, customizable system possible, and worry about performance later.
The first thing you can do to ensure better performance is turn caching on (System -> Cache Management). This will relieve some of the CPU/disk blocking that goes on while Magento is building up its various XML trees.
The second thing you’ll want to do is ensure your host and operations team has experience performance tuning Magento. If you’re relying on the $7/month plan to see you through, well, good luck with that.
September 5, 2009 at 11:48 am in reply to: How to prevent line breaks in list items using CSS #10101
abctest483MemberUse
white-space: nowrap;[1] [2] or give that link more space by settingli‘s width to greater values.
[1] § 3. White Space and Wrapping: the white-space property – W3 CSS Text Module Level 3
[2] white-space – CSS: Cascading Style Sheets | MDN
abctest483MemberYou can’t catch parse errors in the same file where error output is enabled at runtime, because it parses the file before actually executing anything (and since it encounters an error during this, it won’t execute anything). You’ll need to change the actual server configuration so that display_errors is on and the approriate error_reporting level is used. If you don’t have access to php.ini, you may be able to use .htaccess or similar, depending on the server.
This question may provide additional info.
- AuthorPosts