Support » Plugin: PHP Code Widget » [Plugin: PHP Code Widget] Generated [pdf] short code not working ..

  • Resolved tanver

    (@tanver)


    Hi All,
    My website is http://floodreliefpakistan.com/, am using the PHP Code Widget – code given below – to generate the following HTML at run time using ul, il tags to format the output.

    [pdf href=”http://floodreliefpakistan.com/pdfdocs/CosmicTechSol.pdf”]CosmicTechSol [/pdf]
    [pdf href=”http://floodreliefpakistan.com/pdfdocs/Cosmic-Tech-Sol.pdf”]Cosmic Tech Sol [/pdf]

    When I place this generated code in the Text Widget it executes perfectly but am unable to get the desired results from this PHP code Widget. The PHP Code which is being executed from within this Widget is

    <?php
    $chArr[] = '-';
    $chArr[] = '.pdf';
    if ($handle = opendir('pdfdocs')) {
      echo '<ul>';
      while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") { ?>
            <li>[pdf href="http://floodreliefpakistan.com/pdfdocs/<?php echo $file; ?>"]<?php echo str_replace($chArr, ' ', $file); ?>[/pdf]</li>
    <?php
        }
      }
      echo '</ul>';
      closedir($handle);
    }
    ?>

    and the output it generates can be observed by visiting the following the URL http://floodreliefpakistan.com/test.php.

    Any help to resolve this issue is highly appreciated.
    TIA

    http://wordpress.org/extend/plugins/php-code-widget/

Viewing 1 replies (of 1 total)
  • I just changed the code – took away the shortcode – and it had worked for me, am putting the code here as it might help someone else, the complete code for the PHP Code Widget is ..

    <?php
    $chArr[] = '-';
    $chArr[] = '.pdf'; 
    
    if ($handle = opendir('pdfdocs')) {
      while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            $pdfdocs[] = $file;
        }
      }
      closedir($handle);
    }
    ?>
    
    <?php
    echo '<ul>';
    foreach($pdfdocs as $pdfdoc) {
      //echo '<li> [pdf href="http://floodreliefpakistan.com/pdfdocs/'.$pdfdoc.'"]View '.str_replace($chArr, " ", $pdfdoc).'[/pdf]</li>';
    ?>
      <li> <a class="pdf" href="http://docs.google.com/viewer?url=http://floodreliefpakistan.com/pdfdocs/<?php echo $pdfdoc; ?>">View <?php echo str_replace($chArr," ", $pdfdoc); ?></a></li>
    <?php
    }
    echo '</ul>';
    unset($pdfdocs);    // it's gone
    ?>

    hope it helps someone.

    The one thing still left desirable is that I would like the google’s document window to open in a new window instead of appearing in the same window.
    TIA

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: PHP Code Widget] Generated [pdf] short code not working ..’ is closed to new replies.