WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
[resolved] Accessing cached content in another webpage on same domain (4 posts)

  1. Brit Albritton
    Member
    Posted 1 year ago #

    Hello everyone. Thanks for a wonderful plugin & great community.

    I'm working to integrate WordPress and Opencart for a client. I'd like to have a single menu, and (of course) for that menu to be administered in WordPress.

    I was hoping to use the simple, tried and true approach of calling 'wp-load.php,' grabbing the menu and styling it. Unfortunately, WordPress and Opencart don't play nicely together. The trouble starts when they define the same constant - DB_PASSWORD - but rapidly gets more complicated from there.

    My idea is to call upon a cached version of the menu, stripping whatever isn't necessary.

    Is this something WPSuperCache might let me do? Any suggestions for getting started?

    Thank you,

    Brit

    http://wordpress.org/extend/plugins/wp-super-cache/

  2. Brit Albritton
    Member
    Posted 1 year ago #

    As a more general question, would it be insane to use a screen-scraping technique to grab said menu? Alternately, can you think of any security risks that might arise from a plugin to output an html version of the menu whenever it is saved?

    Sorry if this is too general. It strikes me as something that could really help us poor benighted Opencart folks, and might also have general utility in WordPress integration. I can't seem to find much on it, though.

  3. Brit Albritton
    Member
    Posted 1 year ago #

    OK. I played around with a few caching plugins (Really Static seemed promising, though the code is poorly commented and what comments there are are often in German) as well as SimpleHTMLDOM, until I realized I was being an idiot. This is really easy.

    So I created a rough draft:

    // no theme output
    define('WP_USE_THEMES', false);
    require_once('wp-load.php');
    
    //output nav menu
    $file="static/nav.tmp";
    
    // load menu to variable
    
    ob_start();
    require_once('wp-content/themes/twenty-twelve-child/opencartheader.php');
    $output = ob_get_contents();
    ob_end_clean();
    
    file_put_contents($file, $output);

    Where "opencartheader.php" is simply the portion of the WordPress header that contains my nav menu.

    My OpenCart template simply loads the file static/nav.tmp. I'll copy the CSS & javascript straight from WordPress.

    I'll strip away the unnecessary includes and create a plugin that will be triggered by menu saves.

    Feel free to chime in with any suggestions. Meanwhile, I hope this helps someone.

  4. Brit Albritton
    Member
    Posted 1 year ago #

    I continued this soliloquy here, where interested readers can find the exciting solution.

    Unbate your breath...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic