How to change default skin in dnn 7 via database? - default

How to change default skin in dnn7 by database?

This is the the query to be used :
UPDATE HostSettings
SET SettingValue = 'your skin address'
WHERE SettingName = 'DefaultPortalSkin'
OR SettingName = 'DefaultAdminSkin'
your skin address format: [G]Skins/SkinMain/skin.ascx

Related

How can I set a default value for partner_ids on mail.compose.message in Odoo14?

iam trying to pass a default value for partner_ids field on mail.compose.message wizard. The wizard is generated from purchase.order, by the send by email function. I have created a new many2many field on purchase order and it holds the res.partner ids that i want to set as the default value of partner_ids on the mail wizard, I basically want to set the ids from the many2many field as the recipients of the mail. I have already tried putting it into context like this, but to no success:
can you please help me?
'recipient_ids = self.recipient_ids.ids
'context.update({'
''default_partner_ids': recipient_ids,')}

How to retrieve the triggered record information in CloudPage Marketing Cloud

I would like to have "Add to Calendar" in the Email. My idea is to write the code to Javascript to generate file.ICS in CloudPage and link it with the button. When the Email receiver clicks on the button, the file.ICS will be downloaded.
I have a Journey Builder which is triggered from Sales Cloud. I have a CloudPage and I would like to retrieve the information of the "Date field" from the triggered record. I quite have no idea how to write the code to retrieve the "Date field" information in CloudPage. Below is the code that I have
%%[
VAR #sid, #jid, #reason, #lue, #lue_prop, #lue_statusCode, #overallStatus, #requestId, #Response, #Status, #Error, #curEmail
SET #sid = AttributeValue("_subscriberkey")
SET #jid = AttributeValue("jobid")
SET #listid = AttributeValue("listid")
SET #batchid = AttributeValue("_jobsubscriberbatchid")
SET #reason = "One Click Unsubscribe"
VAR #subscriberRows,#result
SET #subscriberRows = RetrieveSalesforceObjects(
"Contact",
"AccountId, Email",
"Id", "=", #sid )
if RowCount(#subscriberRows) == 1 then
VAR #subscriberRow, #AccountId
SET #subscriberRow = Row(#subscriberRows, 1)
SET #AccountId = Field(#subscriberRow, "AccountId")
SET #curEmail = Field(#subscriberRow, "Email")
endif
]%%
I would recommend using a parameter on the url. You can construct a url to use in your button using the CloudPagesUrl() function. It would look something like the below. You can continue to add params as you wish.
%%[
set #url = CloudPagesUrl([YOURCLOUDPAGEID],'ParamNameToPass',#ParamValueToPass)
/* if needed */
set #url = URLEncode(#url)
]%%
NOTE: sometimes you will need to use URLEncode() so that the date is properly formatted in your url string. I usually would do that in the
and in the email, wrap the link in a RedirectTo():
<a href="%%=#RedirectTo(#url)=%%">
and in the CloudPage (assuming it works like a microsite - please verify) use the RequestParameter() function and ask for the string value you used as the 'ParamNameToPass'
set #cloudPageVar = RequestParameter('ParamNameToPass')
Lastly, I highly recommend the function guide page on the dev site - it really helped me understand what was possible in AmpScript.

Wordpress addon to add data to a database and then call the data

I know this question is probably going to get downvoted and I will probably get into trouble but I am hoping someone may be able to help me with my situation.
On my site I use json to download data from an external source, and then I style it beautifully.
Within the json data is an individual ID for each data set.
What I want to accomplish is to have a database where I can insert the ID and a url link.
I have created the table within the wordpress database via phpMyAdmin, but I want to create a page within the admin section where I can simply add the data in.
For displaying the json data I use a php insert addon, within that php clip i want to do a piece of code that checks the database for the id within my custom database and displays the link.
I will be honest I don't know where to start on this, even if its just a link to a source that shows me how to create an admin page and submit data to the database within wordpress dashboard.
I really appreciate any help given and like I say I know I should try harder, but when ever I do a search all I get is 100's of references to add an admin to the database manually.
Thanks,
Adam
Edit I just realized I never put any table information in my question.
The table name within wordpress is called: wp_home_tickets
within that are 3 fields: id (auto increasement), gameid (numeric) and ticketlink (text)
thanks.
For adding a custom settings page in your admin, use the Settings API https://codex.wordpress.org/Settings_API
Here is a nice tutorial using it https://deliciousbrains.com/create-wordpress-plugin-settings-page/#wp-settings-api
To fetch data from your custom table, use the wpdb class https://developer.wordpress.org/reference/classes/wpdb/. More specifically, you can use wpdb::get_results if you will have multiple rows sharing the same id https://developer.wordpress.org/reference/classes/wpdb/get_results/
Or wpdb::get_row if you will ever only have one https://developer.wordpress.org/reference/classes/wpdb/get_row/
Hope this helps you out!
For anyone wishing to see how it was done, here is how I did it.
I created a file in my theme called db_admin_menu.php and added the following to it:
<?php
function ticket_admin_menu() {
global $team_page;
add_menu_page( __( 'Tickets', 'sports-bench' ), __( 'Tickets', 'sports-bench' ), 'edit_posts', 'add_data', 'ticket_page_handler', 'dashicons-groups', 6 ) ;
}
add_action( 'admin_menu', 'ticket_admin_menu' );
function ticket_page_handler() {
$table_name = 'wp_home_tickets';
global $wpdb;
echo '<form method="POST" action="?page=add_data">
<label>Team ID: </label><input type="text" name="gameid" /><br />
<label>Ticket Link: </label><input type="text" name="ticketlink" /><br />
<input type="submit" value="submit" />
</form>';
$default = array(
'gameid' => '',
'ticketlink' => '',
);
$item = shortcode_atts( $default, $_REQUEST );
$gameid = $item['gameid'];
if ($wpdb->get_var("SELECT * FROM wp_home_tickets WHERE gameid = $gameid ")) { echo 'Ticket already exists for this game.'; goto skip; }
if (!empty($_POST)) { $wpdb->insert( $table_name, $item ); }
skip:
}
?>
I then put this code in my script that fetches and displays the json:
$matchid = $match['id'];
$ticket_url = $wpdb->get_var("SELECT ticketlink FROM wp_home_tickets WHERE gameid = '$matchid' ");
if ($ticket_url) { echo 'Get Tickets'; }
I hope someone does find it of use, i did have to use a wordpress plugin called `Insert PHP Code Snippet' by xyzscripts to be able to snippet the php to a shortcode, but that is not the purpose of this post.
Thanks again for your help.

How to update the database after transaction?

I have a Drupal 7 site that has a customized theme installed on it and we have also added some new tables and extended some others.
Right now I have set up Ubercart for selling our products based on the taxonomy. When the purchase is complete I need to update a custom table in MySQL so I made a proc to do that.
In MySQL the created a proc that will do the updating of the tables that I need, all I need to pass into the proc is the uid (same as from the users table) and an id of the taxonomy that was selected during purchase.
I have created the following code to make the call but I am not sure what the best way to pass in the uid and tid to the proc? Should I be using rules within Drupal?
<?php
$mysqli = new mysqli("mysite.com", "user", "password", "db1");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
if (!$mysqli->query("CALL UpdateUserDestList(uID, tID")) {
echo "CALL failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
?>
You can fire your code after a purchase using Ubercart's hook_uc_checkout_complete(). You will want to define that in a custom module, not from within the theme since this is business logic not display information. From within the hook you will have access to both the order and the user account that placed the order.
When working with Drupal, or any other framework really, you should leverage the built-in tools when you can to benefit from the structures they provide.
// Get the Drupal database connection and change the statement class to PDOStatement.
// Save the current class for cleanup later.
$conn = Database::getConnection();
$saved_class = $conn->getAttribute(PDO::ATTR_STATEMENT_CLASS);
$conn->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement'));
// Prepare the statement and bind params
$statement = $conn->prepare("Call GetNodeList(?,?)");
$op_status = $statement->bindParam(1, $node_type, PDO::PARAM_STR | PDO::PARAM_INPUT_OUTPUT, 25);
$op_status = $statement->bindParam(2, $publish_state, PDO::PARAM_INT | PDO::PARAM_INPUT_OUTPUT);
// Execute the statement and reset the connection's statement class to the original.
$exec_result = $statement->execute();
$conn->setAttribute(PDO::ATTR_STATEMENT_CLASS, $saved_class);
// Get your data
while ($row = $statement->fetchColumn(0)) {
// ...
}
Code taken from: https://drupal.stackexchange.com/questions/32708/how-to-execute-stored-procedures-in-drupal which in turn cites: http://public-action.org/content/stored-procedures-and-drupal-7

Drupal 7 load profile2 programmatically

I have two profile2 profiles defined - main and customer_profile. Also, I have a node type called Customer.
When creating a new Customer node, I would like to load the custom_profile form. The idea is to create a node and a profile simultaneously.
I know it's definately a hook_form_alter solution but can someone tell me how to programmatically load a profile while creating or editing a Customer node.
You can load profile type and data by using these function
$types = profile2_get_types();
profile2_load_by_user($account, $type_name = NULL)
For Example :
$types = profile2_get_types();
if (!empty($types)) {
foreach ($types as $type) {
$profile = profile2_load_by_user($uid, $type->type);
}
}
Even if you are able to load the customer_profile form, you will need to handle the values separately as they are two different nodes.
I would suggest capturing those fields in the customer node form, and then create a customer_profile programmatically from the values.
If you want to get the profile2 form itself then you can use something like
module_load_include('inc', 'profile2_page', 'profile2_page');
$profile2 = profile2_by_uid_load($uid, 'seeker_profile');
$entity_form = entity_ui_get_form('profile2', $profile2, 'edit');
and then add that to the form you want to place it in.
You can load full profile data using profile2_load_by_user();
params like:-
profile2_load_by_user($account,$type_name)
$account: The user account to load profiles for, or its uid.
$type_name: To load a single profile, pass the type name of the profile to load
So code like bellow
$account->uid = $existingUser->uid;
$type_name = 'user_about';
$profile = profile2_load_by_user($account, $type_name);
//$profile variable have full data of profile fields
//changing data profile2 fields
if(isset($_POST['field_user_first_name'])&& !empty($_POST['field_user_first_name'])){
$profile->field_user_first_name['und'][0]['value'] = $_POST['field_user_first_name'];
}
profile2_save($profile);
Well When creating a new Profile , Profile2 fields are not visible until a manual save is done.
To Automatically create the profile2 object , We use rules Module
Step
1) Go to Drupal admin/config/workflow/rules
2) create new rule
3) Give a name and Select in react/event "After saving a new user account"
4) Action,>> Add Action >> Execute custom PHP code
5) insert php code
$profile = profile_create(array('type' => 'profile2 type machine name', 'uid' => $account->uid));
profile2_save($profile);
6)Save >> Save changes.
This will create profile2 field when a new user is Created.
I had a similar need for creating a custom tab at the user page and loading the user profile2 form in it.
Here is a snap code of how I managed to accomplish just that:
MYMODULE.module https://gist.github.com/4223234
MYMODULE_profile2_MYPROFILE2TYPE.inc https://gist.github.com/4223201
Hope it helps.

Resources