9 maj 2008

Usuwanie komentarza ze strony przy wykorzystaniu removeChild

<h1>tytul</h1>
<p>tresc tresc tresc tresc tresc tresc tresc</p>
<h5>komentarz</h5>

<p>tresc tresc tresc tresc tresc tresc tresc</p>
<h5>komentarz2</h5>

<script type="text/javascript">
  function usun() {
    while (element = document.getElementsByTagName('h5')[0]) {
      element.parentNode.removeChild(element);
    }
  }
</script>
<a href="javascript:usun()">usuń komentarz</a>
9 maj 2008

Upload plików na serwer

<?php
  if(!empty($_FILES["file_img"]))
  {

    include 'config.php';
    include PATH_INCLUDE . 'function_convert.php';

    $upload_dir = PATH."images/img/";
    $file_tmp  = $_FILES["file_img"]["name"];
    $file_dot  = strrpos($file_tmp, '.');
    $file_name = substr($file_tmp, 0, $file_dot);
    $file_ext  = substr($file_tmp, $file_dot);
   
    $upload_img = $upload_dir . convert_pozycjonowanie($file_name).$file_ext;

    if(move_uploaded_file($_FILES["file_img"]["tmp_name"], $upload_img))
    {
      $file_save = 1;
    }
  }
?>

<FORM METHOD=POST enctype="multipart/form-data">
<INPUT TYPE="file" name="file_img" style="height: 25;"> <input type="submit" name="zapisz" value="zapisz obraz" style="height: 25;"><br> <? if($file_save) echo 'Plik został zapisany.'?>
</FORM>  

9 maj 2008

Uruchomieni edytora tinyMCE w dwóch polach formularza

Inicjalizacja w JS: 

<script language="javascript" type="text/javascript" src="../edytor/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
  tinyMCE.init({
    mode: "exact",
    elements: "strona_fragment",
    theme: "simple"
  });

  tinyMCE.init({
    mode: "exact",
    elements: "strona_tresc",
    theme: "advanced"
  });
</script>

Kod formularza HTML:

<form action="" method="post">
  <textarea id="strona_fragment" name="strona_fragment" cols="60" rows="4" class="mceSimple"></textarea>
  <textarea id="strona_tresc" name="strona_tresc" cols="60" rows="15" class="mceAdvanced"></textarea>
</form>
7 maj 2008

WordPress - Własny schemat odnośników

/%category%/%postname%/

konieczne jest dodanie reguł mod_rewrite do pliku .htaccess

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
</IfModule>