fc2 ワードプレス移行

/wp-content/plugins/movabletype-importer/movabletype-importer.php

if( !empty($line) )
$line .= “\n”;
↓ 空改行を反映してくれるようになる。
//if( !empty($line) )
$line .= “\n”;

$post->post_excerpt .= $line;
↓ コメントアウトしないと、一覧表示時、本文の先頭100文字くらいが表示されなくなる。
↓ (抜粋に空文字が入ってしまう)
//$post->post_excerpt .= $line;

Drupal Twig

$form[‘field_name’][$value[‘id’]] = [
‘#type’ => ‘table’, ‘#tag’ => ‘tr’,
‘#attributes’ => [‘style’ => ‘display:none’]
];

$form[‘field_name’][$value[‘id’]] = [
‘#id’ => ‘field_name’, ‘#type’ => ‘hidden’, ‘#value’ => 1,
‘#prefix’ => ‘1’, // 1<input type=”hidden”> みたいな表示になる
];

$form[‘input’][‘button_on_off’] = [
‘#type’ => ‘hidden’, ‘#value’ => $button_flag,
];

{{dump(_context|keys)}}

{{ content.field_col_name.0[‘#text’]|striptags|replace({‘&nbsp;’:”, ‘\r\n’:”, ‘\n’:”, ‘\r’:”})|slice(0,50)|raw }}
{% if “now”|date(‘Y-m-d H:i:s’) > content.field_col_date.0[‘#markup’]|date(‘Y^m^d H:i:s’) %}
{% set get_param = get_paramter(‘nid.content.param’) %}
{{ content.view_name_view_page_section }}
{% set item_array = item_array(content.field_col_name.0[‘#text’]) %}
{% if content.field_col_item.getValue()|first.value > 0 %}
{% for item in items if not break %}{{ item.content }}{% if loop.index == 4 %}{% set break = true %}{%- endif -%}

{% set rows_count = ((rows|length) / 8) | round(0, ‘cell’) %}

{% set get_color = drupal_field(‘field_col_coler’, ‘node’, get_param) %}
{{ drupal_field(‘field_col_link’, ‘node’, 3) }}
{{ drupal_view(‘view_name’, ‘view_page_section’) }}

{{ label.0[‘#context’].value|length > 10 ? label.0[‘#context’].value|slice(0, 10) ~ ‘…’ : label.0[‘#context’].value }}

{% if paragraph.field_col_link.0.url.toString() is empty %}

{{ row.cells.0.context[‘color_flag’] }}

{% if path(‘<current>’) == ‘/cart’ %}
{% url(‘<current>’)[‘#markup’]|split(‘/’)|last == get_paramter(‘nid.content.top’) %}

drupal.libraries.yml

item:
js:
js/link-and-url.js: {preprocess: false}

{{ attach_library(‘drupal/item’) }}

WORDPRESS ホーム全文表示

wp-content/themes/tortuga/template-parts/content.php

<?php tortuga_post_image_archives(); ?> 削除
<?php tortuga_post_image_single(); ?> 追加

<?php the_excerpt(); ?> 削除
<?php the_content(); ?> 追加
<?php tortuga_entry_tags(); ?> 追加

■スマホでは全文表示したくない場合

<?php if ( wp_is_mobile() ) : ?>
<?php tortuga_post_image_archives(); ?>
<?php else: ?>
<?php tortuga_post_image_single(); ?>
<?php endif; ?>

<?php if ( wp_is_mobile() ) : ?>
<?php the_excerpt(); ?>
<?php else: ?>
<?php the_content(); ?>
<?php tortuga_entry_tags(); ?>
<?php endif; ?>

cakephp3 バリデーション

->add(‘zip’, [
    ‘num’ => [‘rule’ => [‘numeric’], ‘message’ => ‘郵便番号をご確認下さい’],
    ‘range’ => [‘rule’ => [‘lengthBetween’, 7, 7], ‘message’ => ‘郵便番号をご確認下さい’],
])

$validator
    ->add(‘username’, [‘len’ => [‘rule’ => [‘maxLength’, 50], ‘message’ => ‘文字数オーバー(50文字以内)’]])
    ->add(‘username’, ‘custom’, [‘rule’ => [$this, ‘checkUsername’], ‘message’ => ‘そのIDは既に登録されています’])
    ->requirePresence(‘username’, ‘create’)
    ->notEmpty(‘username’);

public function checkUsername($value, $context)
{
    if($this->find()->where([‘username’ => $value])->count() > 0){
        return false;
    }
    return true;
}

cakephp3 FormHelper

■control
$this->Form->control(‘item_category_id’, [‘label’ => [‘text’ => ‘カテゴリー選択’], ‘options’ => $itemCategories])

■input
$this->Form->input($key . ‘.no’, array_merge($input_set, [‘oninput’ => ‘input_set(‘ . $key . ‘)’]))

■hidden
$this->Form->hidden(‘chk_flg_’ . $key, [‘value’ => 0])

■checkbox
$this->Form->checkbox(‘all’, [‘style’=> ‘margin:0 0 0 0;’, ‘hiddenField’ => false, ‘checked’ => false, ‘onClick’ => ‘allchk(“item_chk[]”);’])

■image
$this->Html->image(“upload_img/” . $item->image, [‘style’ => ‘width:100px;height:auto;’])

■link
$this->Html->link(‘【カートを確認】’, [‘controller’ => ‘Carts’, ‘action’ => ‘index’])

■postLink
$this->Form->postLink(‘削除’, [‘action’ => ‘delete’, $item->id], [‘confirm’ => __(‘削除します # {0}?’, $item->name)])

■button
$this->Form->button(‘戻る’, [‘name’ => ‘back’, ‘style’ => ‘margin-right:1rem;’])

■element
$this->element(‘menu/menu’)

■親テーブルの値
h($item->item_category->name)

■create
<?= $this->Form->create(null, [‘url’ => [‘action’ => $act], ‘name’ => ‘index’]) ?><?= $this->Form->end() ?>

■foreach
<?php foreach ($items as $key => $item): ?><?php endforeach; ?>

■if
<?php if ($item->flg == 0): ?>あり<?php else: ?>なし<?php endif; ?>

cakephp3 クエリビルダ

■find

$this->paginate = [
    ‘limit’ => 10,
    ‘order’ => [‘Items.no’ => ‘desc’]
];

$items = $this->Items->find();
$items->select($this->Items);
$items->select($this->Items->ItemCategories);
$items->select([‘cart’ => ‘ IF(Carts.id IS NULL, 0, 1) ‘]);
$items->leftJoin([‘Carts’ => ‘carts’], [‘Carts.user_id = ‘ . $this->Auth->user(‘id’), ‘Carts.item_id = Items.id’, ‘Carts.flg = 0’]);
$items->contain([‘ItemCategories’]);
$items->where([‘Items.name like’ => ‘%’. $this->request->data[‘search_txt’] . ‘%’]);

$items = $this->paginate($items);

■countとfirst

$this->Users->find()->where([‘role’ => ‘user’])->count()
$this->Users->find()->where([‘role’ => ‘user’])->order([‘Users.modified’ => ‘ASC’])->first()

■updateAll

$this->Carts->updateAll([‘flg’ => 1], [‘user_id’ => $this->Auth->user(‘id’)]);