1 (edited by 2016-04-01 19:01:43)

Topic: How to make a field and then be replaced by html code ?

Hello !, I need someone to support me with the following in cutenews 2.0.3:

goal: replacing field { slider } by html code to generate an image gallery within short -story or full -story .

1. Within the menu add news , I need the user to be asked whether to add ( for example) there is a slider using a checkbox .

2. A folder with the name ID of the news (for example /uploads/news/new-{news - id} for example) is automatically generated.

3. The user has a button to load the images into the folder you created earlier .

4. Implementing this php script((code below)) to generate the final HTML code.

5. Replace the field (eg { slider } ) within short -story or full -story above the html code generated .

thanks!!!
https://cutephp.com/forum/uploads/monthly_04_2016/post-151863-1459537263.png

<!-- gallery -->
            
            <?php
                # SETTINGS
                $max_width_img = 350;
                $max_height_img = 350;
                
                function getPictureType($ext) {
                    if ( preg_match('/jpg|jpeg/i', $ext) ) {
                        return 'jpg';
                    } else if ( preg_match('/png/i', $ext) ) {
                        return 'png';
                    } else if ( preg_match('/gif/i', $ext) ) {
                        return 'gif';
                    } else {
                        return '';
                    }
                }
                
                function getPictures() {
                    global $max_width_img, $max_height_img;
                    $dir = SERVDIR.'/uploads/news/new-'.$id;  //the path to the folder is incomplete, it has to be implemented to generate the folder respectively the id 
                    $dir = 'images'; //use this for test without cutenews
                    if (!file_exists($dir)) {
                            
                            mkdir($dir, 0777, true);
                    }
                                        
                    if (is_dir($dir)) {
                        if ( $handle = opendir($dir) ) {
                            $lightbox = rand();
                            $my_code= '<ul id="pictures">';
                            while ( ($file = readdir($handle)) !== false ) {
                                if ( !is_dir($file) ) {
                                    $split = explode('.', $file); 
                                    $ext = $split[count($split) - 1];
                                    if ( ($type = getPictureType($ext)) == '' ) {
                                        continue;
                                    }
                                    if ( ! is_dir($dir.'/thumbs') ) {
                                        mkdir($dir.'/thumbs',0777, true);
                                    }
                                    if ( ! file_exists($dir.'/thumbs/'.$file) ) {
                                        if ( $type == 'jpg' ) {
                                            $src = imagecreatefromjpeg($dir.'/'.$file);
                                        } else if ( $type == 'png' ) {
                                            $src = imagecreatefrompng($dir.'/'.$file);
                                        } else if ( $type == 'gif' ) {
                                            $src = imagecreatefromgif($dir.'/'.$file);
                                        }
                                        if ( ($oldW = imagesx($src)) < ($oldH = imagesy($src)) ) {
                                            $newW = $oldW * ($max_width_img / $oldH);
                                            $newH = $max_height_img;
                                        } else {
                                            $newW = $max_width_img;
                                            $newH = $oldH * ($max_height_img / $oldW);
                                        }
                                        $new = imagecreatetruecolor($newW, $newH);
                                        imagecopyresampled($new, $src, 0, 0, 0, 0, $newW, $newH, $oldW, $oldH);
                                        if ( $type == 'jpg' ) {
                                            imagejpeg($new, $dir.'/thumbs/'.$file);
                                        } else if ( $type == 'png' ) {
                                            imagepng($new, $dir.'/thumbs/'.$file);
                                        } else if ( $type == 'gif' ) {
                                            imagegif($new, $dir.'/thumbs/'.$file);
                                        }
                                        imagedestroy($new);
                                        imagedestroy($src);
                                    }
                                    $my_code.= ' * [url=]';
                                    $my_code.= '[img]'.$dir.[/img]';
                                    $my_code.= '[/url]
';
                                }
                            }
                            $my_code.= '</ul>';
                            closedir($handle);
                        }
                    }//echo $my_code;
                }
            ?>
             
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UFT-8" />
<title>Pictures</title>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<style type="text/css">
#pictures li {
    float:left;
    height:<?php echo ($max_height + 10); ?>px;
    list-style:none outside;
    width:<?php echo ($max_width + 10); ?>px;
    text-align:center;
}
img {
    border:0;
    outline:none;
}
</style>
</head>
<body>


<?php getPictures(); ?>//call function


<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
</body>
</html>
                
            
            
            <!-- end gallery -->

Re: How to make a field and then be replaced by html code ?

Hello !, I need someone to support me with the following in cutenews 2.0.3:

goal: replacing field { slider } by html code to generate an image gallery within short -story or full -story .

1. Within the menu add news , I need the user to be asked whether to add ( for example) there is a slider using a checkbox .

2. A folder with the name ID of the news (for example /uploads/news/new-{news - id} for example) is automatically generated.

3. The user has a button to load the images into the folder you created earlier .

4. Implementing this php script((code below)) to generate the final HTML code.

5. Replace the field (eg { slider } ) within short -story or full -story above the html code generated .

thanks!!!
https://cutephp.com/forum/uploads/monthly_04_2016/post-151863-1459537263.png

<!-- gallery -->
            
            <?php
                # SETTINGS
                $max_width_img = 350;
                $max_height_img = 350;
                
                function getPictureType($ext) {
                    if ( preg_match('/jpg|jpeg/i', $ext) ) {
                        return 'jpg';
                    } else if ( preg_match('/png/i', $ext) ) {
                        return 'png';
                    } else if ( preg_match('/gif/i', $ext) ) {
                        return 'gif';
                    } else {
                        return '';
                    }
                }
                
                function getPictures() {
                    global $max_width_img, $max_height_img;
                    $dir = SERVDIR.'/uploads/news/new-'.$id;  //the path to the folder is incomplete, it has to be implemented to generate the folder respectively the id 
                    $dir = 'images'; //use this for test without cutenews
                    if (!file_exists($dir)) {
                            
                            mkdir($dir, 0777, true);
                    }
                                        
                    if (is_dir($dir)) {
                        if ( $handle = opendir($dir) ) {
                            $lightbox = rand();
                            $my_code= '<ul id="pictures">';
                            while ( ($file = readdir($handle)) !== false ) {
                                if ( !is_dir($file) ) {
                                    $split = explode('.', $file); 
                                    $ext = $split[count($split) - 1];
                                    if ( ($type = getPictureType($ext)) == '' ) {
                                        continue;
                                    }
                                    if ( ! is_dir($dir.'/thumbs') ) {
                                        mkdir($dir.'/thumbs',0777, true);
                                    }
                                    if ( ! file_exists($dir.'/thumbs/'.$file) ) {
                                        if ( $type == 'jpg' ) {
                                            $src = imagecreatefromjpeg($dir.'/'.$file);
                                        } else if ( $type == 'png' ) {
                                            $src = imagecreatefrompng($dir.'/'.$file);
                                        } else if ( $type == 'gif' ) {
                                            $src = imagecreatefromgif($dir.'/'.$file);
                                        }
                                        if ( ($oldW = imagesx($src)) < ($oldH = imagesy($src)) ) {
                                            $newW = $oldW * ($max_width_img / $oldH);
                                            $newH = $max_height_img;
                                        } else {
                                            $newW = $max_width_img;
                                            $newH = $oldH * ($max_height_img / $oldW);
                                        }
                                        $new = imagecreatetruecolor($newW, $newH);
                                        imagecopyresampled($new, $src, 0, 0, 0, 0, $newW, $newH, $oldW, $oldH);
                                        if ( $type == 'jpg' ) {
                                            imagejpeg($new, $dir.'/thumbs/'.$file);
                                        } else if ( $type == 'png' ) {
                                            imagepng($new, $dir.'/thumbs/'.$file);
                                        } else if ( $type == 'gif' ) {
                                            imagegif($new, $dir.'/thumbs/'.$file);
                                        }
                                        imagedestroy($new);
                                        imagedestroy($src);
                                    }
                                    $my_code.= ' * [url=]';
                                    $my_code.= '[img]'.$dir.[/img]';
                                    $my_code.= '[/url]
';
                                }
                            }
                            $my_code.= '</ul>';
                            closedir($handle);
                        }
                    }//echo $my_code;
                }
            ?>
             
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UFT-8" />
<title>Pictures</title>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<style type="text/css">
#pictures li {
    float:left;
    height:<?php echo ($max_height + 10); ?>px;
    list-style:none outside;
    width:<?php echo ($max_width + 10); ?>px;
    text-align:center;
}
img {
    border:0;
    outline:none;
}
</style>
</head>
<body>


<?php getPictures(); ?>//call function


<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
</body>
</html>
                
            
            
            <!-- end gallery -->


Hello Shixel,

The code you provided is not clear enough to understand. According to the above instructions, the code can not ne used {slider} for switching the news on and off this way.

We can provide you with the most suitable way of using this code:

1. You have to correct the following:

after   global $max_width_img, $max_height_img;
goes   if (empty($_REQUEST['id'])) return; else $id = $_REQUEST['id'];
 
instead of     $dir = 'images'; //use this for test without cutenews
it has to be   $local = 'uploads/news/new-'.$id;

instead of  $my_code.= ' * [url=]';
         $my_code.= '[img]'.$dir.[/img]';
         $my_code.= '[/url]
';

should be    $my_code.= ' * [url=]';
         $my_code.= '[img]'.$local.[/img]';
         $my_code.= '[/url]
';

(replace $dir to $local)


2. You have to put this code after include show_news.php, otherwise SERVDIR won`t be identified
3. Uncomment  }//echo $my_code; to echo $my_code
4. To add the feature specifying an option of showing the {slider}, you have to:

change <?php getPictures(); ?>   to   <?php include 'cn_api.php'; $e = cn_api_get_entry();
if (!empty($e['mf']['slider'])) getPictures(); ?>

5. Please remember, that uploads/news/new-'.$id   folders are filled manually from the gallery, but not from news.

Hope this helps!

Best regards,
CN Support team

Re: How to make a field and then be replaced by html code ?

Damn! Looks like this forum is not being updated properly. Any other recommended resources guys? Thx!

Re: How to make a field and then be replaced by html code ?

Support team - thanks! I had similar problem and It certainly helped me. Great job!

5 (edited by graceni 2020-11-03 04:37:27)

Re: How to make a field and then be replaced by html code ?

wrote a program using javascript for showing error message beside field instead of alerting but it is not working please help me to work the program
AlaskasWorld
<html>
   <head>
      <link rel="stylesheet" type="text/css" href="mystyle.css">
      <script type="text/javascript">
         function check()
         {
              if(document.getElementById('firstname').value==NULL || myform.firstname.value.length==0)
              {
                  document.getElementById('errorname').value="this is an invalid name";
              }
         }
      </script>
   </head>
   <body>
      <form name="myform">
         <p>name</p>
         <input type="text" name="firstname" onblur="check()"/>
         <span id="errorname"></span>
         <br/><input type="button" value="submit" />
      </form>
   </body>
</html>

Re: How to make a field and then be replaced by html code ?

Если вы ищете незабываемые моменты интимного удовольствия в Москве, то вы попали по адресу. Platinum Escort - это престижная компания, предоставляющая интим услуги высочайшего качества в столице. Наш интим сайт создан для того, чтобы помочь вам осуществить ваши самые сокровенные фантазии и желания.
Platinum Escort предлагает широкий спектр интимных услуг, чтобы удовлетворить самые изысканные предпочтения клиентов. Наша команда профессиональных и привлекательных партнеров готова встретиться с вами для создания незабываемых моментов интимного удовольствия. Мы гарантируем конфиденциальность, уютную атмосферу и высокий уровень сервиса.
Мы понимаем, что каждый клиент уникален, и поэтому Platinum Escort предлагает индивидуальный подход к каждой встрече. Мы стремимся понять ваши предпочтения и желания, чтобы создать интимную атмосферу, соответствующую вашим ожиданиям. Наши партнеры и партнерки обладают привлекательной внешностью, интеллектом и элегантностью, гарантируя незабываемый опыт.
При использовании нашего интим сайта Platinum Escort вы можете быть уверены в полной конфиденциальности и безопасности. Мы строго соблюдаем приватность всех наших клиентов и обеспечиваем анонимность во время наших встреч. Ваше удовольствие и комфорт - наш главный приоритет.
Не упустите возможность погрузиться в мир интимного удовольствия с Platinum Escort. Посетите наш интим сайт прямо сейчас и выберите партнера или партнерку, который лучше всего отвечает вашим предпочтениям. Мы гарантируем вам незабываемый опыт и море удовольствия.

На нашем сайте вас ждут самые лучшие предложения.  интим в москве