Empty attributes with distributed indexes - search

When i search in distributed index i have empty attributes
[matches] => Array
(
[9] => Array
(
[weight] => 1
[attrs] => Array
(
)
)
[28] => Array
(
[weight] => 1
[attrs] => Array
(
)
)
My sphinx.conf
#!/usr/local/bin/php
source base_src
{
type = xmlpipe2
}
<?php for($i=1;$i<=6;$i++): ?>
source main_src_<?php echo $i; ?> : base_src
{
xmlpipe_command = /usr/local/bin/php /home/yanovskiy/project/indexer.php --main <?php echo ($i - 1); ?>
}
<?php endfor; ?>
index base_index
{
docinfo = extern
mlock = 1
morphology = none
min_word_len = 3
charset_type = utf-8
enable_star = 0
html_strip = 0
}
<?php for($i=1;$i<=6;$i++): ?>
index main_index_<?php echo $i; ?> : base_index
{
source = main_src_<?php echo $i; ?>
path = /var/db/sphinxsearch/data/main_<?php echo $i; ?>
}
<?php endfor; ?>
index dist
{
type = distributed
<?php for($i=1;$i<=6;$i++): ?>
local = main_index_<?php echo $i; ?>
<?php endfor; ?>
}
I have the same schemas in all indexes. I checked it with indextool --dumpheader and manually.
When I search in *main_index_1* or *main_index_2* separately then all is well, but if i search in dist index - attributes are empty. Can anybody help me with this?
I use Sphinx 2.1.2-release on FreeBSD 9.2

This problem in PHP extension from PECL (Version 1.3.0)

I had the same problem here until we upgraded to the latest release of Sphinx server (2.2.10)

Related

Get Post List Custom Post type Category Wise

I want to display all posts as list category wise of a custom post type.
for Ex.:
demo Cat 1
- Post of category demo 1
- Post of category demo 1
- Post of category demo 2
- Post of category name 2
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => -1, //show all posts
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => $term->slug,
)
)
);
$posts = new WP_Query($args);
if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post(); ?>
<?php if(has_post_thumbnail()) { ?>
<?php the_post_thumbnail(); ?>
<?php }
/* no post image so show a default img */
else { ?>
<img src="<?php bloginfo('template_url'); ?>/assets/img/default-img.png" alt="<?php echo get_the_title(); ?>" title="<?php echo get_the_title(); ?>" width="110" height="110" />
<?php } ?>
<?php echo get_the_title(); ?>
<?php the_excerpt(); ?>
<?php endwhile; endif; ?>
https://wordimpress.com/loop-through-categories-and-display-posts-within/

Yii 2 dropdown value safe newbie

I heard building Data in View is not very good, but anyway, i am wondering why its not working:
View
<?php $form = ActiveForm::begin();
$alleSpieler = \common\models\Spieler::find()->all();
if ($alleSpieler) {
unset($types);
foreach ($alleSpieler as $value) {
$types[$value->id] = $value->email . ' ' . $value->vorname . ' ' . $value->nachname;
}
}
echo $form->field($model, 'spielerId')->dropDownList($types, 'prompt'=>'Spieler manuell hinzufügen']);
ActiveForm::end();
?>
<?= AnmeldungDurchfuehrung2::widget(['durchfuehrungId' => $model->id, 'spielerId' => $model->spielerId]) ?>
Model
public $spielerId;
But spielerId ist not set in my Case. If i, for example, set 'spielerId' => 1120 in the widget call, it is working. But if i want the value from the dropdownlist, the action is saying that spielerId is missing. I am newbie and perhaps i forgot something? Thank you!
You must add $spielerId; in validation array in your model, som like this:
public function rules()
{
return [
[['spielerId'], 'integer'], //type of atribute value
[['spielerId'], 'required'], //if need
/*... other atributes ...*/
];
}
for more detail check the documentation.
okay now i know what i need:
echo $form->field($model, 'spielerId')->dropDownList($types,['prompt'=>'Waehlen Sie einen Spieler']);
echo Html::submitButton('Auswählen', ['class' => 'btn btn-primary']);
This is my Dropdown.
I need something like:
<?php if(!empty($_GET['spielerId'])) {
echo AnmeldungDurchfuehrung2::widget(['durchfuehrungId' => $model->id, 'spielerId' => $_GET['subject']]); }?>

Pass values from url to another redirected url

zero.php
<?php
$q = $_GET['id'];
echo = $q
?>
this code is not working, Help me!
I am not using .htaccess in this.
Try this.
<?php
$q = $_GET['value'];
echo $q;
Your syntax is significantly off.
Have you tried?
<?php
$q = $_GET['id'];
echo $q;
?>
and of course this is assuming that there is a GET parameter called id it is being passed so a even better solution would be to check to see if it is defined first.
<?php
if (isset($_GET['id'])) {
$q = $_GET['id'];
echo $q;
} else {
echo "ID PARAMETER NOT SET";
}
?>

Get post_meta of one post type who is different of display post

I'm looking for to get "get_post_meta" from a post type which is different of the display post ?
here is my code , but this display the post_meta of all posts in the post type !
I think it could be compare the posts who have the same slug (post_name) , but I don't know how to do !
<?php $sectionscontact = new WP_query(array('post_type' => 'sections-contact', 'post_count'=>1));if ($sectionscontact->have_posts()): while ( $sectionscontact->have_posts() ) : $sectionscontact->the_post(); $telephone_meta_empty = get_post_meta(451,'telephone', true);
if ( ! empty ( $telephone_meta_empty ) ) { ?>
<div class="tp_titre_bloc" style="border-right:1px solid #999999;"> Téléphone</div>
<div class="tp_content_bloc">
<?php echo get_post_meta(get_the_ID(), 'telephone', true); ?>
</div>
<?php } ?>
What I've done here is to tidy it up for you.
Also, it displays the post_meta for everything in this post type because you're using post_count as opposed to posts_per_page, which is the correct term to display some certain amount of posts in one query.
So, Instead of this:
<?php
$sectionscontact = new WP_query( array(
'post_type' => 'sections-contact',
'post_count' => 1
));
if ($sectionscontact->have_posts()):
while ( $sectionscontact->have_posts() ) :
$sectionscontact->the_post();
$telephone_meta_empty = get_post_meta(451,'telephone', true);
if ( ! empty ( $telephone_meta_empty ) ) { ?>
<div class="tp_titre_bloc" style="border-right:1px solid #999999;">Téléphone</div>
<div class="tp_content_bloc">
<?php echo get_post_meta(get_the_id(), 'telephone', true); ?>
</div>
<?php } ?>
You want this:
<?php
$sectionscontact = new WP_query( array(
'post_type' => 'sections-contact',
'posts_per_page' => 1 //changed post_count to posts_per_page
));
if ($sectionscontact->have_posts()):
while ( $sectionscontact->have_posts() ) :
$sectionscontact->the_post();
$telephone_meta_empty = get_post_meta(451,'telephone', true);
if ( ! empty ( $telephone_meta_empty ) ) { ?>
<div class="tp_titre_bloc" style="border-right:1px solid #999999;">Téléphone</div>
<div class="tp_content_bloc">
<?php echo get_post_meta($post->ID, 'telephone', true); // changed get_the_id() to $post->ID?>
</div>
<?php } ?>
Let me know if that helps.
More info on WP_Query: http://codex.wordpress.org/Class_Reference/WP_Query
Thanks.

PHPExcel reading xls file, get cell styling (font-weight, color, etc)

I am trying to read an excel file and render it as a html table. I would like to get the style that has been applied in excel to a cell and render it in html as well. For example, some cells may have text in BOLD, how do I get that information and use it in the most efficient way?
This is the code I have so far (I am trying out PHPExcel the first time so I am eager to hear any comments or improvements I can make to this):
if ($_GET["xls"]) {
require_once("classes/PHPExcel.php");
$objPHPExcel = PHPExcel_IOFactory::load( dirname(__FILE__) . "/demo.xls" );
$sheetData = $objPHPExcel->getSheetByName('Sheet1')->toArray(null,true,true,true);
?>
<?php if ( count($sheetData) < 0) : ?>
<table class="table striped">
<?php foreach( $sheetData as $y => $row ) : ?>
<tr>
<?php foreach ( $row as $x => $cell) : ?>
<?php if ( $x === "A" ) : ?>
<th><?php echo $cell; ?></th>
<?php else : ?>
<td><?php echo $cell; ?></td>
<?php endif; ?>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<?php
}
Why not take a look at PHPExcel's existing HTML Writer: that already handles merged cells, cell formatting (including borders), font styles, etc.
It seems that the following code works:
$objPHPExcel->getSheetByName('Sheet1')->getStyle("B13")->getFont()->getBold()

Resources