官术网_书友最值得收藏!

Creating views

We're going to create two view files in this section, as follows:

  • /path/to/codeigniter/application/models/views/create/create.php
  • /path/to/codeigniter/application/models/views/nav/top_nav.php

Don't forget that the navigation file (views/nav/top_nav.php) is unique to each chapter in this book.

Creating the view file–views/create/create.php

The create.php file is the view file that the user creating the shortened URL will see; it contains the HTML form the user will enter the original URL into and any interactive elements such as error or success messages.

Create the create/create.php view file and add the following code to it:

      <div class="page-header">
        <h1><?php echo $this->lang->line('system_system_name'); ?></h1>
      </div>

      <p><?php echo $this->lang->line('encode_instruction_1'); ?></p>

      <?php if (validation_errors()) : ?>
        <?php echo validation_errors(); ?>
      <?php endif ; ?>

      <?php if ($success_fail == 'success') : ?>
        <div class="alert alert-success">
          <strong><?php echo $this->lang->line('common_form_elements_success_notifty'); ?></strong> <?php echo $this->lang->line('encode_encode_now_success'); ?> 
        </div>
      <?php endif ; ?>

      <?php if ($success_fail == 'fail') : ?>
        <div class="alert alert-danger">
          <strong><?php echo $this->lang->line('common_form_elements_error_notifty'); ?> </strong> <?php echo $this->lang->line('encode_encode_now_error'); ?> 
        </div>
      <?php endif ; ?>

      <?php echo form_open('create') ; ?>
        <div class="row">
          <div class="col-lg-12">
            <div class="input-group">
              <input type="text" class="form-control" name="url_address" placeholder="<?php echo $this->lang->line('encode_type_url_here'); ?>">
              <span class="input-group-btn">
                <button class="btn btn-default" type="submit"><?php echo $this->lang->line('encode_encode_now'); ?></button>
              </span>
            </div><!-- /input-group -->
          </div><!-- /.col-lg-6 -->
        </div><!-- /.row -->
      <?php echo form_close() ; ?>

      <br />

      <?php if ($encoded_url == true) : ?>
        <div class="alert alert-info">
          <strong><?php echo $this->lang->line('encode_encoded_url'); ?> </strong> 
          <?php echo anchor($encoded_url, $encoded_url) ; ?>
        </div>
      <?php endif ; ?>

Creating the view file–views/nav/top_nav.php

Each project in this book has its own navigation bar at the top of the page. This chapter is no exception although the actual navigation options for this project are limited—mostly because the app we're building only really does one thing. So create the nav/top_nav.php view file and add the following code to it:

<!-- Fixed navbar -->
<div class="navbarnavbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><?php echo $this->lang->line('system_system_name'); ?></a>
</div>
<div class="navbar-collapse collapse">
<ul class="navnavbar-nav">
<li class="active"><?php echo anchor('create', 'Create') ; ?></li>
</ul>
</div><!--/.navbar-collapse -->
</div>
</div>

<div class="container theme-showcase" role="main">
主站蜘蛛池模板: 东乌珠穆沁旗| 开化县| 屯昌县| 芦山县| 庐江县| 元江| 定远县| 綦江县| 尚义县| 佛冈县| 白朗县| 教育| 敦化市| 蒲江县| 永清县| 开鲁县| 肥乡县| 孙吴县| 嘉兴市| 香河县| 新竹县| 湟源县| 唐河县| 都昌县| 竹溪县| 吉林省| 天长市| 肃北| 峨眉山市| 芦山县| 芦山县| 建宁县| 北辰区| 琼结县| 兴化市| 抚顺县| 旺苍县| 县级市| 松原市| 孝感市| 富平县|