Campaign thread
DB
Add the value campaign
to the field thread_type
to the table thread
:
Add the value sms
to the field content_type
to the table node_content
:
Create the table content_sms
:
`content_id` INT(10) UNSIGNED NOT NULL,
`locale` enum('en','fr') NOT NULL DEFAULT 'fr',
`text` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `izendsms_content_sms` ADD PRIMARY KEY (`content_id`,`locale`);
ALTER TABLE `izendsms_content_sms` MODIFY `content_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT;
Configuration
In the file config.inc, add to thread type campaign
to the parameter $supported_threads
:
- global $supported_threads;
- $supported_threads=array('thread', 'folder', 'story', 'book', 'rss', 'newsletter', 'campaign'); // 'thread', 'folder', 'story', 'book', 'rss', 'newsletter'
Add the description of a sms
content to the parameter $contents_model
:
- global $contents_model, $supported_contents, $limited_contents;
- $contents_model = array(
- 'text' => array('text' => array('type' => 'string', 'null' => true), 'eval' => array('type' => 'boolean', 'default' => false)),
- 'infile' => array('path' => array('type' => 'string', 'null' => true)),
- 'download' => array('name' => array('type' => 'string', 'null' => true), 'path' => array('type' => 'string', 'null' => true)),
- 'file' => array('path' => array('type' => 'string', 'null' => true), 'start' => array('type' => 'number', 'default' => 0), 'end' => array('type' => 'number', 'default' => 0), 'format' => array('type' => 'string', 'null' => true), 'lineno' => array('type' => 'boolean', 'default' => true)),
- 'youtube' => array('id' => array('type' => 'string', 'null' => true), 'width' => array('type' => 'number', 'default' => 0), 'height' => array('type' => 'number', 'default' => 0), 'miniature' => array('type' => 'string', 'null' => true), 'title' => array('type' => 'string', 'null' => true), 'autoplay' => array('type' => 'boolean'), 'controls' => array('type' => 'boolean'), 'fs' => array('type' => 'boolean'), 'rel' => array('type' => 'boolean'), 'theme' => array('type' => 'enum', 'default' => 'dark')),
- // 'longtail' => array('file' => array('type' => 'string', 'null' => true), 'image' => array('type' => 'string', 'null' => true), 'width' => array('type' => 'number', 'default' => 0), 'height' => array('type' => 'number', 'default' => 0), 'icons' => array('type' => 'boolean'), 'skin' => array('type' => 'string', 'null' => true), 'controlbar' => array('type' => 'enum', 'default' => 'none'), 'duration' => array('type' => 'number', 'default' => 0), 'autostart' => array('type' => 'boolean'), 'repeat' => array('type' => 'boolean')),
- 'sms' => array('text' => array('type' => 'string', 'null' => true)),
- );
Add the type sms
to the parameter $supported_contents
:
- $supported_contents=array('text', 'infile', 'download', 'file', 'youtube', 'sms'); // 'text', 'infile', 'download', 'file', 'youtube', 'longtail'
Limit the types of contents of the thread type campaign
to sms
by editing the parameter $limited_contents
:
- $limited_contents=array('rss' => array('text'), 'newsletter' => array('text'), 'campaign' => array('sms'));
Code
Add the option campaign
to the selector for the type of thread in the view editing/threadeditsummary
in English and in French:
- <?php elseif ($type == 'campaign'): ?>
- <option value="campaign"<?php if ($thread_type == 'campaign'): ?> selected="selected"<?php endif; ?>>Campaign</option>
- <?php endif; ?>
- <?php elseif ($type == 'campaign'): ?>
- <option value="campaign"<?php if ($thread_type == 'campaign'): ?> selected="selected"<?php endif; ?>>Campagne</option>
- <?php endif; ?>
Add the option campaign
to the selector for the type of thread in the view editing/threadeditall
in English and in French:
- <?php elseif ($type == 'campaign'): ?>
- <option value="campaign"<?php if ($new_thread_type == 'campaign'): ?> selected="selected"<?php endif; ?>>Campaign</option>
- <?php endif; ?>
- <?php elseif ($type == 'campaign'): ?>
- <option value="campaign"<?php if ($new_thread_type == 'campaign'): ?> selected="selected"<?php endif; ?>>Campagne</option>
- <?php endif; ?>
Add processing a content type sms
in the view editing/nodecontenteditor
in English and in French:
- <?php elseif ($type == 'sms'): ?>
- <option value="sms" <?php echo $selected == 'sms' ? 'selected="selected"' : ''; ?>>SMS</option>
- <?php endif; ?>
Adds the option sms
to the selector for the content type.
- $content_sms_text='';
Initializes the variable containing the text of the SMS bebore extracting the data collected by the block nodecontenteditor
.
- <?php case 'sms': ?>
- <label>SMS:</label>
- <?php break; ?>
Displays the label of the content.
- <?php case 'sms': ?>
- <textarea id="content_sms_text_<?php echo $i; ?>" name="content_sms_text[<?php echo $i; ?>]" cols="80" rows="5"><?php echo htmlspecialchars($content_sms_text, ENT_COMPAT, 'UTF-8'); ?></textarea>
- <?php break; ?>
Displays the input field of the text of a SMS.
Adds displaying a content of type sms
to the view nodecontent
:
- case 'sms':
- $text = $c['text'];
- if ($text) {
- echo '<div class="sms">', PHP_EOL;
- echo '<p>', htmlspecialchars($text, ENT_COMPAT, 'UTF-8'), '</p>', PHP_EOL;
- echo '</div>', PHP_EOL;
- }
- break;
- default:
Adds preparing the parameters of the view for a content of type sms
in the block nodecontent
:
- case 'sms':
- $text=$c['content_sms_text'];
- $contents[] = compact('type', 'text');
- break;
Test
Connect as an administrator.
Navigate in the editor to the list of threads.
Create a thread of type Campaign
with the title Bar Foo
.
NOTE: This thread contains all the campaigns managed by a client. In a next chapter, we will automatically create it when a new user is registered.
Edit the thread Bar Foo
.
Create a content with the title The web engine
.
Edit it.
Enter First promotional campaign of iZend for software editors
for the abstract and the keywords iZend web engine
in the cloud.
Add a content of type SMS
.
Type Create your multimedia website in a few minutes with iZend - The web engine: http://www.izend.org
for the text of the SMS.
a type # or #
contents
Display the node.
Create your multimedia website in a few minutes with iZend - The web engine: http://www.izend.org
Git
- /izendsms.com
- blocks
- nodecontent.php
- includes
- config.inc
- views
- nodecontent.phtml
- en
- editing
- nodecontenteditor.phtml
- threadeditall.phtml
- threadeditsummary.phtml
- editing
- fr
- editing
- nodecontenteditor.phtml
- threadeditall.phtml
- threadeditsummary.phtml
- editing
- blocks
Commit this version:
$ git status
$ git add blocks/nodecontent.php includes/config.inc views/en/editing/nodecontenteditor.phtml views/en/editing/threadeditall.phtml views/en/editing/threadeditsummary.phtml views/fr/editing/nodecontenteditor.phtml views/fr/editing/threadeditall.phtml views/fr/editing/threadeditsummary.phtml views/nodecontent.phtml
$ git commit -m'Adds thread type campaign'
IMPORTANT: Edit the DB connector in the file includes/db.inc. Follow the instructions in the file SMS to update the DB.
Comments