i am working on an existing project. I am tyring to use
$params = array(
$this->prefixId.'[cmd]' => 'SINGLE',
$this->prefixId.'[uid]' => intval( $item['uid'] ),
$this->prefixId.'[chash]' => substr( md5( $item['uid'] ), 0, 8 ),
$this->prefixId.'[page]' => $this->GPvars['page'],
);
$link = '<a href="'.str_replace( '&', '&', $this->pi_getPageLink( $this->conf['pidSingle'], '_self', $params ) ).'" target="_self" title="'.$submarks['###SINGLE###'].'">';
$this->pi_getPageLink is not returning anything.
class.tslib_pibase.php is
function pi_getPageLink($id,$target='',$urlParameters=array()) {
return $this->cObj->getTypoLink_URL($id,$urlParameters,$target);
}
That functions need parameters. You should get error messages. Read the API.
$this->cObj->getTypoLink_URL(
123, // ID of the page where you link to
array('test' => 1, 'bar' => 'yes'),
''
);
But i usually use the typolink function. You can use there any typoscript option for typolink:
$this->cObj->stdWrap_typolink(
'',
array(
'returnLast' => 'url',
'parameter' => 123,
'additionalParams' => '&test=1&bar=yes',
)
);
This solution can't work:
$this->cObj->stdWrap_typolink(
'',
array(
'returnLast' => 'url',
'parameter' => 123,
'additionalParams' => '&test=1&bar=yes',
)
);
This one works:
$this->cObj->stdWrap_typolink(
'',
array('typolink' => array(
'returnLast' => 'url',
'parameter' => 123,
'additionalParams' => '&test=1&bar=yes',
)
);
Related
Realurl generates the page URIs from the page title. In a multidomain environment there happen to be some pages with the same title, like "contact" or "imprint". It seems as if realurl cannot discriminate those URLs:
http://www.domain1.com/contact/
http://www.domain2.com/contact/
They always lead to the first URL found in the realurl database table, in the example above "http://www.domain1.com/contact/". Is there a way to avoid this?
This is the reaurl configuration:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']=array(
'_DEFAULT' => array(
'init' => array(
'appendMissingSlash' => 'ifNotFile,redirect',
'emptyUrlReturnValue' => '/',
),
'pagePath' => array(
'rootpage_id' => '123',
),
'fileName' => array(
'defaultToHTMLsuffixOnPrev' => 0,
'acceptHTMLsuffix' => 1,
'index' => array(
'print' => array(
'keyValues' => array(
'type' => 98,
),
),
),
),
),
'www.domain1.de' => '_DEFAULT',
'domain1.de' => 'www.domain1.de',
'www.domain2.de' => '_DEFAULT',
'www.domain2.de' => array(
'pagePath' => array(
'rootpage_id' => '456',
),
),
'domain2.de' => 'www.domain2.de',
);
Generally, this means that rootpage_id settings is either incorrect or not set in your config. RealURL does not have any issues when you have the same titles for various domains as soon as you configured root page ids correctly.
This is the correct snytax:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = array(
'init' => array(
'appendMissingSlash' => 'ifNotFile,redirect',
'emptyUrlReturnValue' => '/',
),
'pagePath' => array(
'rootpage_id' => '123',
),
'fileName' => array(
'defaultToHTMLsuffixOnPrev' => 0,
'acceptHTMLsuffix' => 1,
'index' => array(
'print' => array(
'keyValues' => array(
'type' => 98,
),
),
),
),
);
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['www.domain1.tld'] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'];
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['domain1.tld'] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['www.domain1.tld'];
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['www.domain2.tld'] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'];
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['www.domain2.tld']['pagePath']['rootpage_id'] = '456';
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['domain2.tld'] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['www.domain2.tld'];
The current realurl configuration can be found with the module "Configuration" -> $GLOBALS['TYPO3_CONF_VARS'. There it can be checked whether the realurl configuration file does what it is supposed to do.
What needs to be in the array in the applicable_formats() function so it only is available on the My home page of the user? I've set my-index to true.
acces.php
<?php
$capabilities = array(
'block/groups:myaddinstance' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'user' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/my:manageblocks'
),
'block/groups:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
);
I've copied access.php from the blocks tutorial and only changed the names
UPDATE - it should be just 'my' rather than 'my-index'.
Also just for completeness, you might want to add all = false
public function applicable_formats() {
return array('all' => false, my' => true);
}
$all = array(
'post_type' => array("pwpd_poll","pwpd_infog"),
'posts_per_page' => wp_is_mobile() ? 3 : 7,
'orderby' => 'post_date',
'order' => 'DESC'
);
$news = array(
'post_type' =>array('pwpd_news'),
'meta_query' => $meta_query_par,
'date_query'=>array(
array(
'year' => $today['year'],
'month' => $today['mon'],
'day' => $today['mday'],
)
)
);
the problem is the $news output is always in the end of the loop the "orderby" doesnt seem to be working and also the "posts_per_page" is not exact in the output.
I want to add a field in the backend of the new news module. For that I created a new extension with 3 files in it:
ext_emconf.php
<?php
$EM_CONF[$_EXTKEY] = array(
'title' => 'Expand news',
'description' => 'Expand news',
'category' => 'fe',
'author' => 'SOG',
'author_email' => '-',
'shy' => '',
'dependencies' => '',
'conflicts' => '',
'priority' => '',
'module' => '',
'state' => 'stable',
'internal' => '',
'uploadfolder' => 0,
'createDirs' => '',
'modify_tables' => '',
'clearCacheOnLoad' => 0,
'lockType' => '',
'author_company' => '',
'version' => '0.1.0',
'constraints' => array(
'depends' => array(
),
'conflicts' => array(
),
'suggests' => array(
),
),
'_md5_values_when_last_written' => '',
'suggests' => array(
),
);
?>
ext_tables.php
<?php
/*if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}*/
$tempColumns = array(
'tx_sogexpandnews_test' => array(
'exclude' => 0,
'label' => 'test',
'config' => array(
'type' => 'text',
'cols' => '30',
'rows' => '5',
)
),
);
t3lib_div::loadTCA('tx_news_domain_model_news');
t3lib_extMgm::addTCAcolumns('tx_news_domain_model_news',$tempColumns,1);
t3lib_extMgm::addToAllTCAtypes('tx_news_domain_model_news','tx_sogexpandnews_test', '', 'after:title'));
?>
ext_tables.sql
#
# Table structure for table 'news'
#
CREATE TABLE tx_news_domain_model_news (
tx_sogexpandnews_test text
);
The field is in the database but I dont see the field in the backend when I wanna create a new news item.
I also checked LocalConfiguation.php and made sure that my extension is under the news extension.
Any idea what I miss?
I can't tell why but I deactived news, updated it and installed it again and now I see the field.
cache - cache - cache ... always cache.
If you need to be sure, always delete everything in typo3temp and flush all cf_* tables in your db.
(deactivating and reinstalling almost does the same)
I've been reading through posts on how to do this but none seem to make sense or work. I have created a custom post type (research) in my functions.php file and a custom taxonomy (classifications). I also have a custom archive page (archive-research.php) for my post type.
I have a category (classification) called "oldresearch" that I would like to exclude from the custom archive template.
Below is my custom post type code. Could someone please help me and let me know where the exclusion code needs to go.
<?php
/* redirect users to front page after login */
function redirect_to_front_page() {
global $redirect_to;
if (!isset($_GET['redirect_to'])) {
$redirect_to = get_option('siteurl');
}
}
add_action('login_form', 'redirect_to_front_page');
if ( function_exists('register_sidebars') )
register_sidebars(3);
add_action('init', 'register_custom_menu');
function register_custom_menu() {
register_nav_menu('custom_menu', __('Custom Menu'));
}
/** Registering Custom Post Type: Research **/
// Register Taxonomy for Research
$labels = array(
'name' => 'Classifications',
'singular_name' => 'Classification',
'search_items' => 'Search Classifications',
'popular_items' => 'Popular Classifications',
'all_items' => 'All Classifications',
'parent_item' => 'Parent Classifications',
'edit_item' => 'Edit Classifications',
'update_item' => 'Update Classifications',
'add_new_item' => 'Add New Classification',
'new_item_name' => 'New Classifications',
'separate_items_with_commas' => 'Separate Classifications with commas',
'add_or_remove_items' => 'Add or remove Classifications',
'choose_from_most_used' => 'Choose from most used Classifications'
);
$args = array(
'label' => 'Classifications',
'labels' => $labels,
'public' => true,
'hierarchical' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'args' => array( 'orderby' => 'term_order' ),
'rewrite' => array( 'slug' => 'research/classifications', 'with_front' => false ),
'query_var' => true
);
register_taxonomy( 'Classifications', 'Research', $args );
// Register Classification Column
add_filter( 'manage_research_posts_columns', 'ilc_cpt_columns' );
add_action('manage_research_posts_custom_column', 'ilc_cpt_custom_column', 10, 2);
function ilc_cpt_columns($defaults) {
$defaults['Classifications'] = 'Classifications';
return $defaults;
}
function ilc_cpt_custom_column($column_name, $post_id) {
$taxonomy = $column_name;
$post_type = get_post_type($post_id);
$terms = get_the_terms($post_id, $taxonomy);
if ( !empty($terms) ) {
foreach ( $terms as $term )
$post_terms[] = "<a href='edit.php?post_type={$post_type}&{$taxonomy}={$term->slug}'> " . esc_html(sanitize_term_field('name', $term->name, $term->term_id, $taxonomy, 'edit')) . "</a>";
echo join( ', ', $post_terms );
}
else echo '<i>No terms.</i>';
}
// Register Custom Post Type
function research_post_type() {
$labels = array(
'name' => _x( 'Research', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Research', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Research', 'text_domain' ),
'parent_item_colon' => __( 'Parent Research', 'text_domain' ),
'all_items' => __( 'All Research', 'text_domain' ),
'view_item' => __( 'View Research', 'text_domain' ),
'add_new_item' => __( 'Add New Research', 'text_domain' ),
'add_new' => __( 'New Research', 'text_domain' ),
'edit_item' => __( 'Edit Research', 'text_domain' ),
'update_item' => __( 'Update Research', 'text_domain' ),
'search_items' => __( 'Search Research', 'text_domain' ),
'not_found' => __( 'No Research found', 'text_domain' ),
'not_found_in_trash' => __( 'No Research found in Trash', 'text_domain' ),
);
$rewrite = array(
'slug' => 'research',
'with_front' => true,
'rewrite_pages' => true,
'rewrite_feeds' => true,
);
$args = array(
'label' => __( 'research', 'text_domain' ),
'description' => __( 'Agri-Gro product research', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', ),
'taxonomies' => array( 'Classifications', 'post_tag' ),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 20,
'menu_icon' => 'http://www.agrigro.com/news/wp-content/uploads/2013/01/Documents-icon.png',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'page',
);
register_post_type( 'research', $args );
}
// Hook into the 'init' action
add_action( 'init', 'research_post_type', 0 );
?>
You can use the pre_get_posts filter in your functions.php in order to alter the query for a specific post_type. This is not the only way to achieve the task,but in my opinion it is quite easiest
UPDATE
You need to exclude a custom taxonomy term from your query so, we have to set a tax_query object, so:
Example:
add_action('pre_get_posts','custom_get_posts');
function custom_get_posts($query) {
// We are not displaying the posts on admin panel and this is the main query
if ( !is_admin() && $query->is_main_query() ) {
//Define the tax_query
$taxquery = array(
array(
'taxonomy' => 'Classifications', // also try lower case, remember a taxonomy name must be in lowercase
'field' => 'slug',
'terms' => array( 'oldresearch' ),
'operator' => 'NOT IN'
)
);
// We are displaying a custom posts type archive
if( $query->is_post_type_archive( 'research' ) ){
$query->set('tax_query', $taxquery );
}
}
}
Hope it helps! Let me know if you get stuck.