This is not a built-in utility, more changes are needed on the source code
Step 1: Go to:
Line 195 var $individual_blocks add new 'search' to var
Find fuction have "create_biolink_" to the last function Add new private function create_biolink_search()
Step 2: Go to
Step 3 Go to:
Step 4 Go to:
File:
File:
Step 5 Go to:
Step 6 Go to /app/languages/english#en#active.php
Done.
Step 1: Go to:
/app/controllers/BiolinkBlockAjax.php
Line 195 var $individual_blocks add new 'search' to var
Find fuction have "create_biolink_" to the last function Add new private function create_biolink_search()
PHP:
private function create_biolink_search() { $_POST['link_id'] = (int) $_POST['link_id']; if(!$link = db()->where('link_id', $_POST['link_id'])->where('user_id', $this->user->user_id)->getOne('links')) { die(); } $type = 'search'; $settings = json_encode([ 'display_countries' => [], 'display_devices' => [], 'display_languages' => [], 'display_operating_systems' => [], ]); db()->insert('biolinks_blocks', [ 'user_id' => $this->user->user_id, 'link_id' => $_POST['link_id'], 'type' => $type, 'location_url' => null, 'settings' => $settings, 'order' => $this->total_biolink_blocks, 'datetime' => \Altum\Date::$date, ]); \Altum\Cache::$adapter->deleteItem('link?link_id=' . $_POST['link_id']); Response::json('', 'success', ['url' => url('link/' . $_POST['link_id'] . '?tab=links')]); }
Step 2: Go to
/plugins/ultimate-blocks/ultimate_blocks.php
add search PHP:
'search' => [ 'type' => 'ultimate', 'icon' => 'fas fa-search', 'color' => '#00ce18', 'has_statistics' => false, 'display_dynamic_name' => false, ],
Step 3 Go to:
/plugins/ultimate-blocks/views/l/biolink_blocks/
add search.php
PHP:
<?php defined('ALTUMCODE') || die() ?>
<div id="<?= 'biolink_block_id_' . $data->link->biolink_block_id ?>" data-biolink-block-id="<?= $data->link->biolink_block_id ?>" class="col-12 my-2"> <input id="txt_search" type="text" class="form-control" placeholder="<?= l('create_biolink_search_modal.input') ?>">
</div>
<?php ob_start() ?>
<script> $('#txt_search').bind('keyup keydown paste', function() { var thisBlock=$(this).closest('div[data-biolink-block-id]').data('biolink-block-id'); var blocks = $('main[id="links"] div[data-biolink-block-id]'); var key = $(this).val(); if (key == '') { $.each(blocks, function(k, v) { $(v).css('display', 'block'); }); } else { $.each(blocks, function(k, v) { if (!removeAccents($(v).text().toLowerCase()).includes(removeAccents(key.toLowerCase())) && $(v).data('biolink-block-id') != thisBlock) $(v).css('display', 'none'); }); } function removeAccents(str) { var AccentsMap = [ "aàảãáạăằẳẵắặâầẩẫấậ", "AÀẢÃÁẠĂẰẲẴẮẶÂẦẨẪẤẬ", "dđ", "DĐ", "eèẻẽéẹêềểễếệ", "EÈẺẼÉẸÊỀỂỄẾỆ", "iìỉĩíị", "IÌỈĨÍỊ", "oòỏõóọôồổỗốộơờởỡớợ", "OÒỎÕÓỌÔỒỔỖỐỘƠỜỞỠỚỢ", "uùủũúụưừửữứự", "UÙỦŨÚỤƯỪỬỮỨỰ", "yỳỷỹýỵ", "YỲỶỸÝỴ" ]; for (var i = 0; i < AccentsMap.length; i++) { var re = new RegExp('[' + AccentsMap[i].substr(1) + ']', 'g'); var char = AccentsMap[i][0]; str = str.replace(re, char); } return str; } });
</script>
<?php \Altum\Event::add_content(ob_get_clean(), 'javascript') ?>
Step 4 Go to:
/themes/altum/views/link/settings/biolink_blocks/
add search folderFile:
search_create_modal.php
PHP:
<?php defined('ALTUMCODE') || die() ?>
<div class="modal fade" id="create_biolink_search" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" data-toggle="modal" data-target="#biolink_link_create_modal" data-dismiss="modal" class="btn btn-sm btn-link"><i class="fa fa-fw fa-chevron-circle-left text-muted"></i></button> <h5 class="modal-title"><?= l('create_biolink_search_modal.header') ?></h5> <button type="button" class="close" data-dismiss="modal" aria-label="<?= l('global.close') ?>"> <span aria-hidden="true">×</span> </button> </div> <p class="text-muted modal-subheader"><?= l('create_biolink_search_modal.subheader') ?></p> <div class="modal-body"> <form name="create_biolink_search" method="post" role="form"> <input type="hidden" name="token" value="<?= \Altum\Middlewares\Csrf::get() ?>" required="required" /> <input type="hidden" name="request_type" value="create" /> <input type="hidden" name="link_id" value="<?= $data->link->link_id ?>" /> <input type="hidden" name="block_type" value="search" /> <div class="notification-container"></div> <div class="text-center mt-4"> <button type="submit" name="submit" class="btn btn-block btn-primary"><?= l('global.submit') ?></button> </div> </form> </div> </div> </div>
</div>
File:
search_update_form.php
PHP:
<?php defined('ALTUMCODE') || die() ?>
<form name="update_biolink_" method="post" role="form"> <input type="hidden" name="token" value="<?= \Altum\Middlewares\Csrf::get() ?>" required="required" /> <input type="hidden" name="request_type" value="update" /> <input type="hidden" name="block_type" value="search" /> <input type="hidden" name="biolink_block_id" value="<?= $row->biolink_block_id ?>" /> <div class="notification-container"></div> <button class="btn btn-block btn-gray-300 my-4" type="button" data-toggle="collapse" data-target="#<?= 'display_settings_container_' . $row->biolink_block_id ?>" aria-expanded="false" aria-controls="<?= 'display_settings_container_' . $row->biolink_block_id ?>"> <?= l('create_biolink_link_modal.display_settings_header') ?> </button> <div class="collapse" id="<?= 'display_settings_container_' . $row->biolink_block_id ?>"> <div <?= $this->user->plan_settings->temporary_url_is_enabled ? null : 'data-toggle="tooltip" title="' . l('global.info_message.plan_feature_no_access') . '"' ?>> <div class="<?= $this->user->plan_settings->temporary_url_is_enabled ? null : 'container-disabled' ?>"> <div class="custom-control custom-switch mb-3"> <input id="<?= 'link_schedule_' . $row->biolink_block_id ?>" name="schedule" type="checkbox" class="custom-control-input" <?= !empty($row->start_date) && !empty($row->end_date) ? 'checked="checked"' : null ?> <?= $this->user->plan_settings->temporary_url_is_enabled ? null : 'disabled="disabled"' ?> > <label class="custom-control-label" for="<?= 'link_schedule_' . $row->biolink_block_id ?>"><?= l('link.settings.schedule') ?></label> <small class="form-text text-muted"><?= l('link.settings.schedule_help') ?></small> </div> </div> </div> <div class="mt-3 schedule_container" style="display: none;"> <div <?= $this->user->plan_settings->temporary_url_is_enabled ? null : 'data-toggle="tooltip" title="' . l('global.info_message.plan_feature_no_access') . '"' ?>> <div class="<?= $this->user->plan_settings->temporary_url_is_enabled ? null : 'container-disabled' ?>"> <div class="row"> <div class="col"> <div class="form-group"> <label for="<?= 'link_start_date_' . $row->biolink_block_id ?>"><i class="fa fa-fw fa-clock fa-sm text-muted mr-1"></i> <?= l('link.settings.start_date') ?></label> <input id="<?= 'link_start_date_' . $row->biolink_block_id ?>" type="text" class="form-control" name="start_date" value="<?= \Altum\Date::get($row->start_date, 1) ?>" placeholder="<?= l('link.settings.start_date') ?>" autocomplete="off" data-daterangepicker > </div> </div> <div class="col"> <div class="form-group"> <label for="<?= 'link_end_date_' . $row->biolink_block_id ?>"><i class="fa fa-fw fa-clock fa-sm text-muted mr-1"></i> <?= l('link.settings.end_date') ?></label> <input id="<?= 'link_end_date_' . $row->biolink_block_id ?>" type="text" class="form-control" name="end_date" value="<?= \Altum\Date::get($row->end_date, 1) ?>" placeholder="<?= l('link.settings.end_date') ?>" autocomplete="off" data-daterangepicker > </div> </div> </div> </div> </div> </div> <div class="form-group"> <label for="<?= 'link_display_countries_' . $row->biolink_block_id ?>"><i class="fa fa-fw fa-globe fa-sm text-muted mr-1"></i> <?= l('create_biolink_link_modal.input.display_countries') ?></label> <select id="<?= 'link_display_countries_' . $row->biolink_block_id ?>" name="display_countries[]" class="form-control" multiple="multiple"> <?php foreach(get_countries_array() as $country => $country_name): ?> <option value="<?= $country ?>" <?= in_array($country, $row->settings->display_countries ?? []) ? 'selected="selected"' : null ?>><?= $country_name ?></option> <?php endforeach ?> </select> <small class="form-text text-muted"><?= l('create_biolink_link_modal.input.display_countries_help') ?></small> </div> <div class="form-group"> <label for="<?= 'link_display_devices_' . $row->biolink_block_id ?>"><i class="fa fa-fw fa-laptop fa-sm text-muted mr-1"></i> <?= l('create_biolink_link_modal.input.display_devices') ?></label> <select id="<?= 'link_display_devices_' . $row->biolink_block_id ?>" name="display_devices[]" class="form-control" multiple="multiple"> <?php foreach(['desktop', 'tablet', 'mobile'] as $device_type): ?> <option value="<?= $device_type ?>" <?= in_array($device_type, $row->settings->display_devices ?? []) ? 'selected="selected"' : null ?>><?= l('global.device.' . $device_type) ?></option> <?php endforeach ?> </select> <small class="form-text text-muted"><?= l('create_biolink_link_modal.input.display_devices_help') ?></small> </div> <div class="form-group"> <label for="<?= 'link_display_languages_' . $row->biolink_block_id ?>"><i class="fa fa-fw fa-language fa-sm text-muted mr-1"></i> <?= l('create_biolink_link_modal.input.display_languages') ?></label> <select id="<?= 'link_display_languages_' . $row->biolink_block_id ?>" name="display_languages[]" class="form-control" multiple="multiple"> <?php foreach(get_locale_languages_array() as $locale => $language): ?> <option value="<?= $locale ?>" <?= in_array($locale, $row->settings->display_languages ?? []) ? 'selected="selected"' : null ?>><?= $language ?></option> <?php endforeach ?> </select> <small class="form-text text-muted"><?= l('create_biolink_link_modal.input.display_languages_help') ?></small> </div> <div class="form-group"> <label for="<?= 'link_display_operating_systems_' . $row->biolink_block_id ?>"><i class="fa fa-fw fa-window-restore fa-sm text-muted mr-1"></i> <?= l('create_biolink_link_modal.input.display_operating_systems') ?></label> <select id="<?= 'link_display_operating_systems_' . $row->biolink_block_id ?>" name="display_operating_systems[]" class="form-control" multiple="multiple"> <?php foreach(['iOS', 'Android', 'Windows', 'OS X', 'Linux', 'Ubuntu', 'Chrome OS'] as $os_name): ?> <option value="<?= $os_name ?>" <?= in_array($os_name, $row->settings->display_operating_systems ?? []) ? 'selected="selected"' : null ?>><?= $os_name ?></option> <?php endforeach ?> </select> <small class="form-text text-muted"><?= l('create_biolink_link_modal.input.display_operating_systems_help') ?></small> </div> </div> <div class="mt-4"> <button type="submit" name="submit" class="btn btn-block btn-primary"><?= l('global.update') ?></button> </div>
</form>
Step 5 Go to:
/app/helpers/Link.php
on function get_biolink_link add search case PHP:
case 'search': $view_path = \Altum\Plugin::get('ultimate-blocks')->path . 'views/l/biolink_blocks/' . $link->type . '.php'; break;
Step 6 Go to /app/languages/english#en#active.php
Code:
'create_biolink_search_modal.header' => 'Add search',
'create_biolink_search_modal.subheader' => 'Add a block search',
'create_biolink_search_modal.input' => 'Type to search',
Done.