PHP - Duda en código

 
Vista:
sin imagen de perfil

Duda en código

Publicado por Luis (4 intervenciones) el 13/07/2015 23:24:35
Hola, Buenas Tardes!
Veran estoy empezando con la programación web y encontré este pequeño código y me gustaría saber si notan un error o algo que no funcione, o una forma más sencilla de escribirlo.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php the_post_thumbnail($columnset.'col-image'); ?>
 
	<?php $preview = ($portfoliotype != 'video') ? wp_get_attachment_url( get_post_thumbnail_id($post->ID) ): extractURL($portfoliometa['portfolio_embedded_code']); ?>
 
	<?php //fallback for selfhosted videos 
	$preview = ($preview == 'unknown') ? wp_get_attachment_url( get_post_thumbnail_id($post->ID) ): $preview; ?>
 
	<a href="<?php echo get_permalink(); ?>">
 
		<div class="hover-overlay">
			<?php if(isset($layout['portfolio_item_title']) && $layout['portfolio_item_title'] != 'on') { ?>
				<h1 class="portfolio-title"><?php echo $title; ?><br /><span><?php echo $projecttypeclean; ?></span></h1>
			<?php } else { ?>
				<span class="circle-hover"><img src="<?php echo get_template_directory_uri(); ?>/images/circle-hover.png" /></span>
			<?php } ?>
		</div>
 
	</a>
 
</div>

Espero me puedan ayudar, la verdad es que me URGEEE
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Duda en código

Publicado por xve (6935 intervenciones) el 14/07/2015 10:34:13
Hol Luis, no se si esta bien, ya que llamas funciones que no se que son, pero creo que poner un div , h1 y span dentro de un <a href> no es del todo correcto.

Veo que cierras un </div> que no se donde lo abres... entiendo que nos has mostrado una parte del código...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Duda en código

Publicado por Luis (4 intervenciones) el 14/07/2015 23:03:54
Es de una pagina de wordpress y es para hacer una galería, pero las imágenes no se ven y cheque el código html y vi que donde iba la imagen estaba así <img src=""> sin el link. Esta parte del código que puse es la que se supone coloca el link de la imagen para que esta se vea.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Duda en código

Publicado por Luis (4 intervenciones) el 15/07/2015 23:22:21
Hola perdón no se si me puedas especificar mas en que parte debo cambiar eso, porque en la que yo veo según yo si esta escrito el "echo". Y el error que tengo no es que no pueda dar click y seguir el link, más bien que no se ve la imagen el thumbnail. Tal vez no es en esa parte del código te dejo el entero:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<?php
 
/* Portfolio Archive
 *
 * lambda framework v 2.1
 * by www.unitedthemes.com
 * since lambda framework v 1.0
 */
 
get_header();
 
#-----------------------------------------------------------------
# switch grid layout
#-----------------------------------------------------------------
 
global $columnset, $paged, $lambda_meta_data;
 
switch ($columnset) {
	case 2:
		$grid = "eight columns";
		$z = 0;
		$counter = 1;
		$width = 460;
		break;
	case 3:
		$grid = "fivep columns";
		$z = 4;
		$counter = 2;
		$width = 300;
		break;
	case 4:
		$grid = "four columns";
		$z = 5;
		$counter = 3;
		$width = 220;
		break;
}
 
#-----------------------------------------------------------------
# Pagination
#-----------------------------------------------------------------
$paged = 1;
if ( get_query_var('paged') ) $paged = get_query_var('paged');
if ( get_query_var('page') ) $paged = get_query_var('page');
 
#-----------------------------------------------------------------
# custom project types for portfolio query
#-----------------------------------------------------------------
$project_types = '';
if(is_array($lambda_meta_data->get_the_value('cb_project_type'))) {
	$project_types = "&project-type=";
	foreach($lambda_meta_data->get_the_value('cb_project_type') as $type) {
		$project_types .= $type.',';
	}
	$project_types = substr($project_types, 0, -1);
}
 
#-----------------------------------------------------------------
# custom project types for portfolio query
#-----------------------------------------------------------------
	$layout = $lambda_meta_data->the_meta();
 
	$posts_per_page = (isset($layout['posts_per_page'])) ? $layout['posts_per_page'] : '9';
	$prev = (isset($layout['portfolio_pre_text'])) ? $layout['portfolio_pre_text'] : 'Anterior';
	$next = (isset($layout['portfolio_next_text'])) ? $layout['portfolio_next_text'] : 'Siguiente';
 
?>
 
 
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<section>
	<article>
		<?php the_content(); ?>
	</article>
</section>
<?php endwhile; // end of the loop. ?>
 
 
<?php
#-----------------------------------------------------------------
# Isotope Effect
#-----------------------------------------------------------------
?>
 
 
	<script type="text/javascript">
	jQuery(document).ready(function($){
 
		$(window).load(function(){
 
			/* IsoTope
			================================================== */
			$container = $('#portfolioItems');
 
			$container.isotope({
			  itemSelector : '.portfolio-item',
			  animationEngine : 'best-available',
			  layoutMode:'fitRows',
			  resizable: false,
			  masonry: { columnWidth: $container.width() / <?php echo $columnset; ?> -20}
			});
 
			var $sortedItems = $container.data('isotope').$filteredAtoms;
 
			$('#filter-items a').click(function(){
			  var selector = $(this).attr('data-filter');
			  $container.isotope({ filter: selector });
 
			  <?php if($columnset != '1') {?>
				$container.find('.last').removeClass('last');
				var i = <?php echo $counter; ?>;
				$.each($sortedItems, function(key, value) {
					if($(this).hasClass("isotope-hidden")) {
						i++;
					}
					if(((key-i)/<?php echo $columnset; ?>)==0) {
						$(this).addClass('last');
						i = <?php echo $columnset; ?>+i;
					}
				});
			  <?php } ?>
 
			  if ( !$(this).hasClass('selected') ) {
					$(this).parents('#filter-items').find('.selected').removeClass('selected');
					$(this).addClass('selected');
			  }
 
			  $container.isotope( 'reLayout');
			  return false;
			});
		});
 
 
		$("#portfolioItems > li > .thumb").stop().hover(function(){
 
			$(this).find('.hover-overlay').stop().fadeIn(250);
 
 
		}, function () {
 
			$(this).find('.hover-overlay').stop().fadeOut(250);
 
		});
 
		$(window).smartresize(function(){
 
		    $container.isotope({
				// update columnWidth to a percentage of container width
				masonry: { columnWidth: $container.width() / <?php echo $columnset; ?> -20}
			});
 
		});
 
	});
	</script>
 
 
<?php
#-----------------------------------------------------------------
# Query Portfolio
#-----------------------------------------------------------------
query_posts('post_type='.UT_PORTFOLIO_SLUG.'&posts_per_page='.$posts_per_page.'&paged='.$paged.'&project_types='.$project_types); ?>
 
<div id="portfolio-container">
 
<?php if(isset($layout['activate_portfolio_filter']) && $layout['activate_portfolio_filter'] == 'on') : ?>
 
<!--start portfolio menu-->
<ul id="filter-items" class="filter_portfolio clearfix">
 
<?php
 
			#-----------------------------------------------------------------
			# get all taxonomys project types
			#-----------------------------------------------------------------
			$taxonomys = get_terms('project-type');
 
 
			#-----------------------------------------------------------------
			# check if there is a sorting array
			#-----------------------------------------------------------------
			if(is_array(get_option('wpalchemy_taxonomy_project-type'))) {
 
				$taxSort = array_sort(get_option('wpalchemy_taxonomy_project-type'), 'SortID' , SORT_ASC);
 
				if(is_array($taxonomys)) {
 
					//run trough taxonomy array
					foreach ($taxonomys as $taxkey => $taxval ) {
 
						//run trough sorting array
						if(isset($taxSort) && is_array($taxSort)) {
							foreach ($taxSort as $sortkey => $sortval) {
 
								if($taxval->term_id == $sortkey) {
 
									$taxonomys[$taxkey]->SortID = $sortval['SortID'];
 
								}
 
							}
						}
					}
 
				}
 
			}
			uasort($taxonomys, "compareItems");
 
			#-----------------------------------------------------------------
			# get all used taxonomy project types
			#-----------------------------------------------------------------
			$used_taxonomys = array();
			if (have_posts()) : while (have_posts()) : the_post();
				if(is_array(wp_get_object_terms( $post->ID, 'project-type'))) {
				foreach (wp_get_object_terms( $post->ID, 'project-type') as $term) {
						$used_taxonomys[$term->term_id] = $term->name;
				} }
 
			endwhile; endif;
 
			#-----------------------------------------------------------------
			# create final sorted portfolio filter
			#-----------------------------------------------------------------
			$portfolio_filter = array();
 
			if(is_array($taxonomys)) {
				$tax = 1;
				foreach ($taxonomys as $key => $value ) {
 
					if($taxonomys[$key]->parent == 0 && isset($taxonomys[$key]->name) && in_array($taxonomys[$key]->name, $used_taxonomys)) {
						echo '<li><a href="#" data-filter="*" class="selected">'.lambda_translate_meta($taxonomys[$key]->name).'</a></li>';
					}
					if(in_array($taxonomys[$key]->name, $used_taxonomys) && $taxonomys[$key]->parent != 0 ) {
						echo '<li><a href="#" data-filter=".'.$taxonomys[$key]->slug.'_filt">'.lambda_translate_meta($taxonomys[$key]->name).'</a></li>';
					}
				$tax++;
				}
			}
 
			?>
 
</ul>
<!--end portfolio menu-->
 
</ul>
<!--end portfolio menu-->
 
<div class="clear"></div>
 
<?php endif; ?>
 
<ul id="portfolioItems" class="clearfix">
	<?php
	if (have_posts()) : while (have_posts()) : the_post(); $lambda_meta_data->the_meta();
 
		global $more;
		$more = 0;
 
		#-----------------------------------------------------------------
		# Portfolio Meta Data & IconSet
		#-----------------------------------------------------------------	
		$portfoliometa = $lambda_meta_data->the_meta();
 
		if(isset($portfoliometa['portfolio_type'])) :
 
		switch ($portfoliometa['portfolio_type']) {
			case 'video_portfolio':
					$portfoliotype = 'video';
					break;
 
			case 'audio_portfolio':
					$portfoliotype = 'audio';
					break;
 
			case 'single_image_portfolio':
					$portfoliotype = 'image';
					break;
 
			case 'image_portfolio':
					$portfoliotype = 'gallery';
					break;
 
			case NULL:
					$portfoliotype = 'standard';
					break;
		}
 
		endif;
 
		$title= str_ireplace('"', '', trim(get_the_title()));
 
		#-----------------------------------------------------------------
		# get all project-types for this item
		#-----------------------------------------------------------------						
		$projecttype = NULL;
		$projecttypeclean = NULL;
 
		$preview = '';
		$unkown = '';
		$singletaxonomy = array();
 
		$project_cats = wp_get_object_terms( $post->ID, 'project-type' );
 
			if(is_array($project_cats)) {
				foreach( $project_cats as $types ){
					$projecttype .=  $types->slug."_filt ";
 
						//run trough sorting array
						if(is_array($taxSort)) {
							foreach ($taxSort as $sortkey => $sortval) {
 
								if($types->term_id == $sortkey && $types->parent > 0) {
									$singletaxonomy[$types->term_id]->SortID = $sortval['SortID'];
									$singletaxonomy[$types->term_id]->name = $types->name;
								}
							}
						}
 
				}
			}
			//cut last whitespace and comma
			uasort($singletaxonomy, "compareItems");
 
			if(is_array($singletaxonomy)) {
				foreach($singletaxonomy as $singleprojecttype) {
					$projecttypeclean.= $singleprojecttype->name.', ';
				}
			}
 
			$projecttypeclean = substr($projecttypeclean,0,-2);
 
		//fallback for selfhosted videos 
		if($portfoliotype != 'video') {
 
				$preview =  wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()) );
 
		} elseif(isset($portfoliometa['portfolio_embedded_code'])) {
 
				$preview = extractURL($portfoliometa['portfolio_embedded_code']);
 
		}
 
		$unkown = $preview; //we need to keep the variable value
 
		#-----------------------------------------------------------------
		# 2-4 Column Layout in first step - alpha - omega or last
		#-----------------------------------------------------------------			
 
		$itemposition = '';	//reset position	
 
		if($columnset !=3) {
			if($columnset == 2) { (($z%2)==0) ? $itemposition = '' : $itemposition = ' last'; }
			if($columnset == 4) { (($z%4)==0) ? $itemposition = ' last' : $itemposition = ''; }
		} else {
			if(($z%3) == 0) { $itemposition = ' last'; $z = 3; }
		}
 
		?>
 
        <li class="portfolio-item <?php echo $grid.$itemposition; ?> <?php echo $projecttype; ?> clearfix">
 
						<div class="thumb remove-bottom clearfix">
						<div class="overflow-hidden">
 
						 <?php
 
						 #-----------------------------------------------------------------
						 # embedded video or image
						 #-----------------------------------------------------------------				 
						 ?>
 
								<?php the_post_thumbnail($columnset.'col-image'); ?>
 
								<?php $preview = ($portfoliotype != 'video') ? wp_get_attachment_url( get_post_thumbnail_id($post->ID) ): extractURL($portfoliometa['portfolio_embedded_code']); ?>
 
								<?php //fallback for selfhosted videos 
								$preview = ($preview == 'unknown') ? wp_get_attachment_url( get_post_thumbnail_id($post->ID) ): $preview; ?>
 
								<a href="<?php echo get_permalink(); ?>">
 
									<div class="hover-overlay">
										<?php if(isset($layout['portfolio_item_title']) && $layout['portfolio_item_title'] != 'on') { ?>
											<h1 class="portfolio-title"><?php echo $title; ?><br /><span><?php echo $projecttypeclean; ?></span></h1>
										<?php } else { ?>
											<span class="circle-hover"><img src="<?php echo get_template_directory_uri(); ?>/images/circle-hover.png" /></span>
										<?php } ?>
									</div>
 
								</a>
 
						</div>
 
                        <?php
						#-----------------------------------------------------------------
						# display title or not
						#-----------------------------------------------------------------
						if($layout['portfolio_item_title'] == 'on') { ?>
 
							<h1 class="portfolio-title-below"><a href="<?php the_permalink(); ?>"><?php echo $title; ?></a><br /><span><?php echo $projecttypeclean; ?></span></h1>
 
						<?php } //endif ?>  
						</div>
 
 
 		</li>
 
		<?php $z++; endwhile; endif; ?>
	</ul>
 
	<div class="clear"></div>
 
    <?php paginate($next,$prev); ?>
 
</div>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Vainas
Val: 34
Ha aumentado su posición en 3 puestos en PHP (en relación al último mes)
Gráfica de PHP

Duda en código

Publicado por Vainas (262 intervenciones) el 16/07/2015 01:26:28
Tienes razon. el que no me habia fijado soy yo.

Lo extraño es que no te muestre el parametro que pones fijo al menos:

1
<img src="/images/circle-hover.png" />

Has intentado imprimir esa variable en el html (sin meterla dentro del src de un img) para ver si el valor que devuelve es el que necesitas?

Tambien la anidacion de elementos puede bloquearte la imagen quizas?.

Yo empezaria por imprimir solo la ruta a ver si esta correcta.

Saludos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar