Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter nattila

    (@nattila)

    If I duplicate the whole thing

    define( 'DYNAMIC_OUTPUT_BUFFER_TAG', 'MY_TAG' );
    if ( DYNAMIC_OUTPUT_BUFFER_TAG != '' ) {
       ....blah blah
    }

    I get “Fatal error: Cannot redeclare dynamic_output_buffer_init()” Error. Which functions should I duplicate or extend if I would like to use more dynamic buffer tags. Please give me some advice.

    Thread Starter nattila

    (@nattila)

    please help me with a short answer. It is a simple question: How to use more than one DYNAMIC_OUTPUT_BUFFER_TAG on same page?

    Thread Starter nattila

    (@nattila)

    is this a trivial question? please help!

    Amanda Giles

    (@shedonist)

    I am working with dynamic caching myself right now, I believe that you could duplicate it, but that the simplest most surefire way to make it all work would be to copy all the functions, add_cacheaction calls, and add_action calls and rename them for each instance. You would also need to update the DEFINE statements as well. You would need to be careful to ensure you got all instances duplicated and matching.

    So
    define( 'DYNAMIC_OUTPUT_BUFFER_TAG', '' );
    could become
    define( 'DYNAMIC_OUTPUT_BUFFER_TAG2', '' );

    and each function would also need updating, so for example here I’ve appended a “2” to the function names and DEFINE constants:

    function dynamic_output_buffer_test2( &$cachedata = 0 ) {
    		if ( defined( 'DYNAMIC_OB_TEXT2' ) )
    			return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG2, DYNAMIC_OB_TEXT2, $cachedata );
    
    		ob_start();
    		// your dynamic content goes here
    		$text = ob_get_contents();
    		ob_end_clean();
    
    		if ( $cachedata === 0 ) { // called directly from the theme so store the output
    			define( 'DYNAMIC_OB_TEXT2', $text );
    		} else // called via the wpsc_cachedata filter. We only get here in cached pages in wp-cache-phase1.php
    			return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG2, $text, $cachedata );
    
    	}
    	add_cacheaction( 'wpsc_cachedata', 'dynamic_output_buffer_test2' );

    Good luck!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Using multiple dynamic parts on the same page’ is closed to new replies.