auto-url

I

icekemia

Guest
i tried to edit some files but it didn't work
i would like to modify a field so that if i write "home" i will get as displayed result in main page home
to be more clear, i add one word and it will be both parameter of a php url and name of the link
it should be the first field of the row
any suggestion on how to do it?

thnx a lot :)
 
A

alpha2zee

Guest
Because DaDaBik is a general form configurator, this will be difficult to achieve without some good code modification.

However, if you use DaDaBik as a backend for something else, as I do (see http://stanxterm.aecom.yu.edu/secondary/ordering/index.php), this is easy to do.

If I were to modify DaDaBik (3.2) for this, I would probably approach it this way:

0. A new field for the form configurator (pattern_replace) will be created. If this field is filled with some text containing say an asterisk *, then then the field value will replace * in the pattern_replace value.

E.g., say your actual form field value is 'home' and in the configurator, you have put, for pattern_replace, '*,' then you will end up with 'home'

1. If you already have DaDaBik installed - meaning DaDaBik has been run once atleast, as a result of which all the dadabik_ tables have been generated in the database:

Using something like phpmyadmin or Navicat, create a new field in all of the dadabik_ tables with these parameters -

pattern_replace
varchar(255)
not null
utf-8_general_ci

This is not needed if you have not run DaDaBik yet.

2. Edit include/internal_table.php

Add at end:

$int_fields_ar[25][0] = "Pattern replacement:";
$int_fields_ar[25][1] = "pattern_replace";
$int_fields_ar[25][2] = "text";
$int_fields_ar[25][3] = "25";

3. Edit admin.php

Look for series of itenms like:

$linked_fields_order_type_field_temp = addslashes($fields_labels_ar[$j]["linked_fields_order_type_field"]);

At end, add:

$pattern_replace_temp = addslashes($fields_labels_ar[$j]["pattern_replace"]);

Look for series of items like:
".$quote."linked_fields_order_type_field".$quote."

Make the end like so by adding:

,".$quote."pattern_replace".$quote;

Look for series of items like:

'$linked_fields_order_type_field_temp'

Make the end like so by adding:

,'$pattern_replace_temp';

[take care of the semi-colns at end - all PHP code lines end with a semi-colon]

4. Edit include/business_logic.php: Go to function create_internal_table($table_internal_name). Towards the end, after:

separator_field varchar(2) NOT NULL default '~',

add:

pattern_replace VARCHAR(255) NOT NULL default '',

Then, go to function_results_table and look for:

$field_separator = $fields_labels_ar[$i]["separator_field"];

After that, add:

$field_pattern = $fields_labels_ar[$i]["pattern_replace"];

Towards the end of this function, look for line beginning '$field_to_display = get_field_correct_displaying...' and change it to:

$field_to_display = get_field_correct_displaying($field_values_ar[$j], $field_type, $field_content, $field_separator, $field_pattern, "results_table"); // get the correct display mode for the field

Then, go to function get_field_correct_displaying. Change the first line to be so:

function get_field_correct_displaying($field_value, $field_type, $field_content, $field_separator, $field_pattern, $display_mode)

Then, replace the part between 'default:' and 'if ($field_content == "email")' (towads the end) with:

if ($field_content !== 'html' and !($field_pattern != '')) {
$field_value = htmlspecialchars($field_value);
if ( $display_mode == "results_table") {
$displayed_part = wordwrap($field_value, $word_wrap_col, "\n", $enable_word_wrap_cut);
} // end if
else {
$displayed_part = $field_value;
} // end else
} // end if
elseif ($field_content !== 'html' and $field_pattern != '') {
$field_value = str_replace('*', $field_value, $field_pattern);
$field_value = htmlspecialchars($field_value);
if ( $display_mode == "results_table") {
$displayed_part = wordwrap($field_value, $word_wrap_col, "\n", $enable_word_wrap_cut);
} // end if
else {
$displayed_part = $field_value;
} // end else
} // end elseif
else {
$displayed_part = $field_value;
} // end else

**************

Above is just a guideline; you may want to do more modifications. E.g., with above, such replacements will not work for exported CSV files. For that, you willl have to modify the function get_field_correct_csv_displaying.
 
I

icekemia

Guest
thanx a lot
i'm gonna try it and i'll let u know if it worked out ;)
 
Top