Jump to content

Marvin

Members
  • Posts

    22
  • Joined

  • Last visited

Posts posted by Marvin

  1. Hi @Jan Romero,

    Thanks for replying, sorry my late reply.

    Oh i see now, but i still confuse about something, i try to learn with trying make some pages, template, and fields at processwire, when i create a templates, theres a menu to import fields from antoher templates, how it works? I mean i try to import some fields from a template call theme_song, and at theme_song has a field, theme, and have value like Christmast, Easter, and etc. When i import the field from theme song to another template, is the value will import it too? Thank you

  2. Hi @Jan Romero,

    Thanks for the feedback

    14 hours ago, Jan Romero said:

    It’s not clear to me what you’re trying to do. Do you mean this? https://en.wikipedia.org/wiki/Single_Table_Inheritance

    Yes, i mean i'm try to create one table at database, that will be a parent table, and on table again that will be a child table and the value of child table is a detail from parent table, and they have a inheritance relationship.

    14 hours ago, Jan Romero said:

    ProcessWire’s data model doesn’t involve inheritance, if that’s what you mean? You can get a pretty good idea of PW’s database strategy by looking at the tables of an existing PW installation.

    Hmm, so i can't do it with a processwire? So if i have a data, like for example sell and buy transaction, that has a invoice number and so many items, what can i do, for it? I mean can i, create a website using a processwire with a data like that? Thank you very much
    NB : Sorry if you can't understand with my question my english not well enough ?

  3. Hi @Marco Ro, sorry for may late reply, yes i can share it

    this is my function to upload an image and a file at the same time

     

    if(!$original || !$indonesia || !$other || !$composer){
          $note = "Data tidak lengkap";
        } else {
          $newFile = new WireUpload("song_files");
          $newFile->setMaxFiles(1);
          $newFile->setOverwrite(false);
          $newFile->setDestinationPath($upload_path);
          $newFile->setValidExtensions(array('pdf','docx','doc'));
          $files = $newFile->execute();
    
          if(!count($files)) {
            $newFile->error("No files received, so not creating page.");
            return false; 
          }
    
          $newImg = new WireUpload("img_files");
          $newImg->setMaxFiles(1);
          $newImg->setOverwrite(false);
          $newImg->setDestinationPath($upload_path);
          $newImg->setValidExtensions(array('jpeg','jpg','png','gif'));
          $images = $newImg->execute();
    
          if(!count($images)) {
            $newImg->error("No files received, so not creating page.");
            return false; 
          }
    
          $newPage = new Page();
          $newPage->template = "files";
          $newPage->parent = $pages->get("/files/");
          $newPage->title = $original;
          $newPage->text_1 = $indonesia;
          $newPage->text_2 = $other;
          $newPage->text_3 = $composer;
          $newPage->text_4 = $video;
          $newPage->text_5 = $audio;
          $newPage->of(false);
          $newPage->save();
    
          foreach($files as $filename) {
            $filepath = $upload_path . '/' . $filename;
            $newPage->files->add($filepath);
            $newPage->message("Add file : $filename");
            unlink($filepath);
          }
          foreach($images as $filename) {  //add this foreach iteration to upload an image
            $filepath = $upload_path.'/'.$filename;
            $newPage->images->add($filepath);
            $newPage->message("Add Image : $filename");
            unlink($filepath);
          }
          $newPage->save();
        }

     

    • Thanks 1
  4. Hi,

    I'm still new at processwire, i want to ask, i was create a website with sign in system, but i want to add a access roles/permission for each user at my website. For now, i just can create a login user without any permission and the user data became as a pages in my processwire.

    Here i attach my code for login

    <?php 
      $note = $note2 = $hidden ="";
    
      if($input->get->id == "logout") {
        $session->remove('login_id');
      }
    
      if($input->post->submit) {
        $email = $sanitizer->email($input->post->email);
        $pass = $sanitizer->text($input->post->pass);
        $result = $pages->find("email=$email, text_1=$pass");
    
      if(!$email || !$pass) {
        $note = "Data belum lengkap";
      } else {
        if($result->count > 0) {
          $session->login_id = "$result";
          $hidden = "style = 'diplay:none'";
          $url=$pages->get("/files/")->httpUrl;
          header("Location:$url");
          die();
        } else {
          $note = "Akun tidak ditemukan";
        }
      }
    }
    ?>

    And this code for login form

    <div class="frow-container">
      <div class="frow centered mt-50">
        <div class="col-md-1-3">
          <div class="box p-40 shadow-light">
            <h2 class="mb-20 text-center" <?=$hidden?>>Database Partitur<br>GII HIT</h2>
            <form method="post" <?=$hidden?>>
              <label>Username <input type="text" name="email"></label>
              <label>Password <input type="password" name="pass"></label>
              <input type="submit" name="submit" value="Masuk">
            </form>
            <p class="notif"><?=$note;?></p>
            <div class="text-center"><?=$note2;?></div>
          </div>
        </div>
      </div>
    </div>

    Just for remember, my user data now is a pages, and i cannot give any permission to user data.

    Thank you very much for help.

  5. Hello,

    My name Marvin and i'm still new at ProcessWire development, i want to change my website authentication system using a PHP and Processwire, i tried to search some reference but get stuck of it, all i want to do just add some roles access to my website authentication system, can some one help me with a suggestion? Thank you very much before.

    Here i attach my code below

    This for authentication, i create a user like the other template. (I mean as a pages).

    <?php 
      $note = $note2 = $hidden ="";
    
      if($input->get->id == "logout") {
        $session->remove('login_id');
      }
    
      if($input->post->submit) {
        $name = $sanitizer->email($input->post->login_name);
        $pass = $sanitizer->text($input->post->login_pass);
        $result = $pages->find("email=$email, text_1=$pass");
    
      if(!$email || !$pass) {
        $note = "Data belum lengkap";
      } else {
        if($result->count > 0) {
          $session->login_id = "$result";
          $hidden = "style = 'diplay:none'";
          $url=$pages->get("/files/")->httpUrl;
          header("Location:$url");
          die();
        } else {
          $note = "Akun tidak ditemukan";
        }
      }
    }
    ?>

    And this is a Login Form

    <div class="frow-container">
      <div class="frow centered mt-50">
        <div class="col-md-1-3">
          <div class="box p-40 shadow-light">
            <h2 class="mb-20 text-center" <?=$hidden?>>Database Partitur<br>GII HIT</h2>
            <form method="post" <?=$hidden?>>
              <label>Username <input type="text" name="login_name"></label>
              <label>Password <input type="password" name="login_pass"></label>
              <input type="submit" name="submit" value="Masuk">
            </form>
            <p class="notif"><?=$note;?></p>
            <div class="text-center"><?=$note2;?></div>
          </div>
        </div>
      </div>
    </div>

     

  6. Hi,

    My name is Marvin, and i want to ask about a processwire, i'm new at processwire, and want to learn make a website using a php and processwire, but i have a problem. My problem is, when i want to uploading an image file, and a document file like a pdf, or doc, but every time i upload it, my image didn't upload to the back-end, just doc file was uploaded to the back-end. Any suggestion where i was wrong? Thank you

    NB : i attach my code below
    This is for uploading process

    <?php
      $note = $note2 = $hidden ="";
      if($input->post->submit){
        $upload_path = $config->paths->assets.'files/upload/';
        if(!is_dir($upload_path)){
          if(!wireMkdir($upload_path)) throw new WireException("No upload path");
        }
        $original = $sanitizer->text($input->post->original);
        $indonesia = $sanitizer->text($input->post->indonesia);
        $other = $sanitizer->text($input->post->other);
        $composer = $sanitizer->text($input->post->composer);
    
        if(!$original || !$indonesia || !$other || !$composer){
          $note = "Data tidak lengkap";
        } else {
          $newFile = new WireUpload("song_files");
          $newFile->setMaxFiles(1);
          $newFile->setOverwrite(false);
          $newFile->setDestinationPath($upload_path);
          $newFile->setValidExtensions(array('pdf','docx','doc'));
          $files = $newFile->execute();
    
          if(!count($files)) {
            $newFile->error("No files received, so not creating page.");
            return false; 
          }
    
          $newImg = new WireUpload("img_files");
          $newImg->setMaxFiles(1);
          $newImg->setOverwrite(false);
          $newImg->setDestinationPath($upload_path);
          $newImg->setValidExtensions(array('jpeg','jpg','png','gif'));
          $images = $newImg->execute();
    
          if(!count($images)) {
            $newImg->error("No files received, so not creating page.");
            return false; 
          }
    
          $newPage = new Page();
          $newPage->template = "files";
          $newPage->parent = $pages->get("/files/");
          $newPage->title = $original;
          $newPage->text_1 = $indonesia;
          $newPage->text_2 = $other;
          $newPage->text_3 = $composer;
          $newPage->of(false);
          $newPage->save();
    
          foreach($files as $filename) {
            $filepath = $upload_path . '/' . $filename;
            $newPage->files->add($filepath);
            $newPage->message("Add file : $filename");
            unlink($filepath);
          }
          $newPage->save();
        }
      }
      
    ?>

    And this if for a form

    <div class="frow-container">
      <form method="post" enctype="multipart/form-data">
        <div class="frow mt-10">
          <div class="col-md-1-1">
            <a href="<?= $pages->get("/files/")->httpUrl ?>"><i class="fas fa-arrow-left"></i> Kembali ke Files</a>
          </div>
          <div class="frow gutters col-md-1-1">
            <div class="col-md-1-2 mt-15">
              <label>Original Song Title <input type="text" name="original"></label>
              <label>Indonesia Song Title <input type="text" name="indonesia"></label>
              <label>Other Song Title <input type="text" name="other"></label>
              <label>Composer <input type="text" name="composer"></label>
              <label>File <input type="file" name="song_files"></label>
            </div>
            <div class="col-md-1-2 mt-15">
              <label>Youtube Video Code <input type="text" name="video"></label>
              <label>Audio Video Code <input type="text" name="audio"></label>
              <label>Image <input type="file" id="attach" name="img_files" accept="image/jpg,image/jpeg/,image/gif,image/png"></label>
            </div>
            <input type="submit" name="submit" value="Save">
          </div>
        </div>
      </form>
    </div>

    Thank you very much for all help

    • Like 1
  7. Hi @kongondo,

    I solved it, i can change a width and height of my image using a css, but now i have one more issue, that is, when i upload an image and a file at the same time, there just a file save it to the processwire, but for image i have to save it manually from back-end. Any suggestion for it? Thank you very much

  8. Hi @kongondo

    It's ok, sorry for my late reply too, i had job to do, lately. I have field for files like for .docx or .pdf, and i have a field for images, but when i try to add a image, from a form the image seems not add to the images field, but that was add to a files field.

    And for your code your suggest, is it place inside foreach iteration or make new foreach iteration?

    For resize a image i don't get any error message, just when i try to reload my page, its showing the result the image cannot resize width or height either, like image i attach below. Thank you

    image.thumb.png.65bf1af02be2843da285956d89f4899a.png

  9. Hello, my name Marvin, i want to ask something. I'm new at processwire, and still learn it, i try yo showing an image, at a table, the image was show, but i can't resize the image

    please HELP

    Here i attach, my code belor

    <?php
                $num = 1;
                foreach($pages->get("/files/")->children as $child) {
                  $current = $child === $page ? " class='current'" : '';
                  $result = $child->images;
                  // $result->width(900);
                  // $result->height(100);
                  foreach($result as $items){
                    foreach($pages->get($child->name)->files as $file) {
                      // $file = $child->files;
                      // echo $file->name;
    
                      echo "<tr><td>".$num++.".</td><td>".$child->title."</td><td>".$child->text_1."</td><td>".$child->text_2."</td><td>".$child->text_3."</td><td><a href='".$file->httpUrl."'>".$file->name."</a></td><td><img src='".$items->url."'></td></tr>";
                    }
                  }
                }
              ?>

     

  10. Hello

    i hava a same problem, but a little bit different. When everyone in here get a 403 Error when migarting from xampp to live server, i get 403 error when i testing my website at a xampp

    Any suggestion for that?

    Here i attach my code where i get an error code 

    foreach($pages->get("/files/")->children as $child) {
                  $page == $child;
                  $pdf = $child->files;
                  echo $pdf->httpUrl; //the url not show anything, but whenif i use $pdf->url, the url will show a file path directory
                  echo "<tr><td>".$num++.".</td><td>".$child->title."</td><td>".$child->text_1."</td><td>".$child->text_2."</td><td>".$child->text_3."</td><td><a href='".$pdf->url."'</a>".$child->files."</td></tr>"; //when i click a url i get 403 error code
                }

     

  11. Hello,

    I'm new at process wire and i want to make an web using upload file and showing it at the table as a link to open it at the new tab. I wa succed while upload a file, but how i showing it as a link at the table to open it at the new tab of my browser? Any suggestion may helpfull

    Here i attach my code below :

    This code is for upload it to back-end (process wire)

    
    <?php
      $note = $note2 = $hidden ="";
      if($input->post->submit){
        $upload_path = $config->paths->assets.'files/upload/';
        if(!is_dir($upload_path)){
          if(!wireMkdir($upload_path)) throw new WireException("No upload path");
        }
        $original = $sanitizer->text($input->post->original);
        $indonesia = $sanitizer->text($input->post->indonesia);
        $other = $sanitizer->text($input->post->other);
        $composer = $sanitizer->text($input->post->composer);
    
        if(!$original || !$indonesia || !$other || !$composer){
          $note = "Data tidak lengkap";
        } else {
          $newFile = new WireUpload("song_files");
          $newFile->setMaxFiles(1);
          $newFile->setOverwrite(false);
          $newFile->setDestinationPath($upload_path);
          $newFile->setValidExtensions(array('pdf','docx','doc'));
          $files = $newFile->execute();
    
          if(!count($files)) {
            $newFile->error("No files received, so not creating page.");
            return false; 
          }
    
          $newImg = new WireUpload("img_files");
          $newImg->setMaxFiles(1);
          $newImg->setOverwrite(false);
          $newImg->setDestinationPath($upload_path);
          $newImg->setValidExtensions(array('jpeg','jpg','png','gif'));
          $files = $newImg->execute();
    
          if(!count($files)) {
            $newImg->error("No files received, so not creating page.");
            return false; 
          }
    
          $newPage = new Page();
          $newPage->template = "files";
          $newPage->parent = $pages->get("/files/");
          $newPage->title = $original;
          $newPage->text_1 = $indonesia;
          $newPage->text_2 = $other;
          $newPage->text_3 = $composer;
          $newPage->of(false);
          $newPage->save();
    
          foreach($files as $filename) {
            $filepath = $upload_path . $filename;
            $newPage->files->add($filepath);
            $newPage->message("Add file : $filename");
            unlink($filepath);
          }
          $newPage->save();
        }
      }
    ?>

    and this code to showing it as a link at the table

    <table class="border">
              <tr>
                <th>No.</th>
                <th>Original Song Title</th>
                <th>Indonesia Song Title</th>
                <th>Other Song Title</th>
                <th>Composer</th>
                <th>File (pdf)</th>
              </tr>
              <?php
                $num = 1;
                $song;
                foreach($pages->get("/files/")->children as $child) { //showing every child at files parent directory
                  $page == $child;
                  $song = $pages->get("/files/".$child->id."/")->files; //showing uploaded files at child directory
                  echo $child->id;
                  echo "<tr><td>".$num++.".</td><td>".$child->title."</td><td>".$child->text_1."</td><td>".$child->text_2."</td><td>".$child->text_3."</td><td><a href='".$song->httpUrl."'</a>".$song->name."</td></tr>";
                }
              ?>
            </table>

    Thank you for any suggestion

  12. Hello, i want to ask, i maintain a website that using a processwire and php, and i want to make an archive at my website using a subfolder system, but when i try,
    the sebfolder is show but when i click the files in that subfolder not show, and my browser just show me an error Invalid argument supplied for foreach(), i don't know why it error

    Here i attach my code and my screenshoot website :

    This is my code

    code.thumb.png.51207362b3f9ca7ac7f4b058d86fca46.png

    This is result of my website

    code1.png.19f0eb5cb7078b9321e963b25007d026.png

    This is my error

    code2.png.e12681bf8fcfd15c881ddc22140e7709.png

     

     

×
×
  • Create New...